Upload the entire dataset.
Browse files- geosql_dataset/ddl/01-state.txt +21 -0
- geosql_dataset/ddl/02-county.txt +23 -0
- geosql_dataset/ddl/03-coastline.txt +8 -0
- geosql_dataset/ddl/04-metropolitan.txt +21 -0
- geosql_dataset/ddl/05-roads.txt +10 -0
- geosql_dataset/ddl/06-military.txt +12 -0
- geosql_dataset/ddl/07-railways.txt +9 -0
- geosql_dataset/geosql-dataset .csv +934 -0
- geosql_dataset/load_tables.sh +25 -0
- geosql_dataset/readme.txt +20 -0
- geosql_dataset/tiger_files/tl_2023_us_cbsa.zip +3 -0
- geosql_dataset/tiger_files/tl_2023_us_coastline.zip +3 -0
- geosql_dataset/tiger_files/tl_2023_us_county.zip +3 -0
- geosql_dataset/tiger_files/tl_2023_us_mil.zip +3 -0
- geosql_dataset/tiger_files/tl_2023_us_primaryroads.zip +3 -0
- geosql_dataset/tiger_files/tl_2023_us_rails.zip +3 -0
- geosql_dataset/tiger_files/tl_2023_us_state.zip +3 -0
geosql_dataset/ddl/01-state.txt
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
CREATE TABLE public.tl_2023_us_state (
|
2 |
+
gid serial4 NOT NULL,
|
3 |
+
region varchar(2) NULL,
|
4 |
+
division varchar(2) NULL,
|
5 |
+
statefp varchar(2) NULL,
|
6 |
+
statens varchar(8) NULL,
|
7 |
+
geoid varchar(2) NULL,
|
8 |
+
geoidfq varchar(11) NULL,
|
9 |
+
stusps varchar(2) NULL,
|
10 |
+
"name" varchar(100) NULL,
|
11 |
+
lsad varchar(2) NULL,
|
12 |
+
mtfcc varchar(5) NULL,
|
13 |
+
funcstat varchar(1) NULL,
|
14 |
+
aland float8 NULL,
|
15 |
+
awater float8 NULL,
|
16 |
+
intptlat varchar(11) NULL,
|
17 |
+
intptlon varchar(12) NULL,
|
18 |
+
geom public.geometry(multipolygon, 4269) NULL,
|
19 |
+
CONSTRAINT tl_2023_us_state_pkey PRIMARY KEY (gid)
|
20 |
+
);
|
21 |
+
|
geosql_dataset/ddl/02-county.txt
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
CREATE TABLE public.tl_2023_us_county (
|
2 |
+
gid serial4 NOT NULL,
|
3 |
+
statefp varchar(2) NULL,
|
4 |
+
countyfp varchar(3) NULL,
|
5 |
+
countyns varchar(8) NULL,
|
6 |
+
geoid varchar(5) NULL,
|
7 |
+
geoidfq varchar(14) NULL,
|
8 |
+
"name" varchar(100) NULL,
|
9 |
+
namelsad varchar(100) NULL,
|
10 |
+
lsad varchar(2) NULL,
|
11 |
+
classfp varchar(2) NULL,
|
12 |
+
mtfcc varchar(5) NULL,
|
13 |
+
csafp varchar(3) NULL,
|
14 |
+
cbsafp varchar(5) NULL,
|
15 |
+
metdivfp varchar(5) NULL,
|
16 |
+
funcstat varchar(1) NULL,
|
17 |
+
aland float8 NULL,
|
18 |
+
awater float8 NULL,
|
19 |
+
intptlat varchar(11) NULL,
|
20 |
+
intptlon varchar(12) NULL,
|
21 |
+
geom public.geometry(multipolygon, 4269) NULL,
|
22 |
+
CONSTRAINT tl_2023_us_county_pkey PRIMARY KEY (gid)
|
23 |
+
);
|
geosql_dataset/ddl/03-coastline.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
CREATE TABLE public.tl_2023_us_coastline (
|
2 |
+
gid serial4 NOT NULL,
|
3 |
+
"name" varchar(100) NULL,
|
4 |
+
mtfcc varchar(5) NULL,
|
5 |
+
geom public.geometry(multilinestring, 4269) NULL,
|
6 |
+
CONSTRAINT tl_2023_us_coastline_pkey PRIMARY KEY (gid)
|
7 |
+
);
|
8 |
+
--A single coastline is divided into different fragments which same name for fragments of the coastline.
|
geosql_dataset/ddl/04-metropolitan.txt
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
CREATE TABLE public.tl_2023_us_cbsa (
|
2 |
+
gid serial4 NOT NULL,
|
3 |
+
csafp varchar(3) NULL,
|
4 |
+
cbsafp varchar(5) NULL,
|
5 |
+
geoid varchar(5) NULL,
|
6 |
+
geoidfq varchar(14) NULL,
|
7 |
+
"name" varchar(100) NULL,
|
8 |
+
namelsad varchar(100) NULL,
|
9 |
+
lsad varchar(2) NULL,
|
10 |
+
memi varchar(1) NULL,
|
11 |
+
mtfcc varchar(5) NULL,
|
12 |
+
aland float8 NULL,
|
13 |
+
awater float8 NULL,
|
14 |
+
intptlat varchar(11) NULL,
|
15 |
+
intptlon varchar(12) NULL,
|
16 |
+
geom public.geometry(multipolygon, 4269) NULL,
|
17 |
+
CONSTRAINT tl_2023_us_cbsa_pkey PRIMARY KEY (gid)
|
18 |
+
);
|
19 |
+
--This table contains data on both metropolitan and micropolitan areas.
|
20 |
+
--To filter metropolitan areas only you need to look at the entries where lsad='M1'
|
21 |
+
--To filter micropolitan areas only you need to look at the entries where lsad='M2'
|
geosql_dataset/ddl/05-roads.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
CREATE TABLE public.tl_2023_us_primaryroads (
|
2 |
+
gid serial4 NOT NULL,
|
3 |
+
linearid varchar(22) NULL,
|
4 |
+
fullname varchar(100) NULL,
|
5 |
+
rttyp varchar(1) NULL,
|
6 |
+
mtfcc varchar(5) NULL,
|
7 |
+
geom public.geometry(multilinestring, 4269) NULL,
|
8 |
+
CONSTRAINT tl_2023_us_primaryroads_pkey PRIMARY KEY (gid)
|
9 |
+
);
|
10 |
+
--A single road is divided among multiple rows with same 'fullname' attribute.
|
geosql_dataset/ddl/06-military.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
CREATE TABLE public.tl_2023_us_mil (
|
2 |
+
gid serial4 NOT NULL,
|
3 |
+
areaid varchar(22) NULL,
|
4 |
+
fullname varchar(100) NULL,
|
5 |
+
mtfcc varchar(5) NULL,
|
6 |
+
aland float8 NULL,
|
7 |
+
awater float8 NULL,
|
8 |
+
intptlat varchar(11) NULL,
|
9 |
+
intptlon varchar(12) NULL,
|
10 |
+
geom public.geometry(multipolygon, 4269) NULL,
|
11 |
+
CONSTRAINT tl_2023_us_mil_pkey PRIMARY KEY (gid)
|
12 |
+
);
|
geosql_dataset/ddl/07-railways.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
CREATE TABLE public.tl_2023_us_rails (
|
2 |
+
gid serial4 NOT NULL,
|
3 |
+
linearid varchar(22) NULL,
|
4 |
+
fullname varchar(100) NULL,
|
5 |
+
mtfcc varchar(5) NULL,
|
6 |
+
geom public.geometry(multilinestring, 4269) NULL,
|
7 |
+
CONSTRAINT tl_2023_us_rails_pkey PRIMARY KEY (gid)
|
8 |
+
);
|
9 |
+
--A single railways is divided into multiple rows with fullname common among them.
|
geosql_dataset/geosql-dataset .csv
ADDED
@@ -0,0 +1,934 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
natural_query,ddl,sql_query
|
2 |
+
"give me a list of 5 closest primary roads near the property located at 7300 20th St Lot 39, Vero Beach, FL 32966.",05-roads.txt,"with property as (
|
3 |
+
SELECT
|
4 |
+
ST_X(geomout) as lon,
|
5 |
+
ST_Y(geomout) as lat
|
6 |
+
from geocode('7300 20th St Lot 39, Vero Beach, FL 32966')
|
7 |
+
limit 1
|
8 |
+
)
|
9 |
+
select fullname, linearid, geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography as dist
|
10 |
+
from public.tl_2023_us_primaryroads, property
|
11 |
+
order by dist
|
12 |
+
Limit 5;"
|
13 |
+
"which is the closest primary road from 7300 20th St Lot 39, Vero Beach, FL 32966 and how far is it?",05-roads.txt,"with property as (
|
14 |
+
SELECT
|
15 |
+
ST_X(geomout) as lon,
|
16 |
+
ST_Y(geomout) as lat
|
17 |
+
from geocode('7300 20th St Lot 39, Vero Beach, FL 32966')
|
18 |
+
limit 1
|
19 |
+
)
|
20 |
+
select fullname, geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography as dist
|
21 |
+
from public.tl_2023_us_primaryroads, property
|
22 |
+
order by dist
|
23 |
+
Limit 1;"
|
24 |
+
give me a list of 5 longest primary roads in the united states.,05-roads.txt,"select fullname, sum(st_length(geom::geography)) as total_length
|
25 |
+
from public.tl_2023_us_primaryroads
|
26 |
+
group by fullname
|
27 |
+
order by total_length desc
|
28 |
+
Limit 5;"
|
29 |
+
how many primary roads are there in the state of florida?,"05-roads.txt,01-state.txt","with state as (
|
30 |
+
select geom as state_geom
|
31 |
+
from public.tl_2023_us_state
|
32 |
+
where name ilike '%florida%'
|
33 |
+
limit 1
|
34 |
+
)
|
35 |
+
select count(*) as num_primary_roads
|
36 |
+
from public.tl_2023_us_primaryroads, state
|
37 |
+
where st_contains(state_geom, geom);"
|
38 |
+
which is the longest primary road in florida?,"05-roads.txt,01-state.txt","with state as (
|
39 |
+
select geom as state_geom
|
40 |
+
from public.tl_2023_us_state
|
41 |
+
where name ilike '%florida%'
|
42 |
+
limit 1
|
43 |
+
)
|
44 |
+
select fullname, st_length(geom::geography) as length
|
45 |
+
from public.tl_2023_us_primaryroads, state
|
46 |
+
where st_contains(state_geom, geom)
|
47 |
+
order by st_length(geom::geography) desc
|
48 |
+
limit 1;"
|
49 |
+
how many primary roads are present in Madison County?,"05-roads.txt,02-county.txt","with county as (
|
50 |
+
select geom as county_geom
|
51 |
+
from public.tl_2023_us_county
|
52 |
+
where namelsad ilike '%madison%'
|
53 |
+
limit 1
|
54 |
+
)
|
55 |
+
select count(*) as num_primary_roads
|
56 |
+
from public.tl_2023_us_primaryroads, county
|
57 |
+
where st_contains(county_geom, geom)
|
58 |
+
limit 1;
|
59 |
+
"
|
60 |
+
which is the longest primary road in Bronx county?,"05-roads.txt,02-county.txt","with state as (
|
61 |
+
select geom as county_geom
|
62 |
+
from public.tl_2023_us_county
|
63 |
+
where name ilike '%bronx%'
|
64 |
+
limit 1
|
65 |
+
)
|
66 |
+
select fullname, st_length(geom::geography) as length
|
67 |
+
from public.tl_2023_us_primaryroads, state
|
68 |
+
where st_contains(county_geom, geom)
|
69 |
+
order by st_length(geom::geography) desc
|
70 |
+
limit 1;"
|
71 |
+
what is the total length of primary roads in Florida?,"05-roads.txt,01-state.txt","with state as (
|
72 |
+
select geom as state_geom
|
73 |
+
from public.tl_2023_us_state
|
74 |
+
where name ilike '%florida%'
|
75 |
+
limit 1
|
76 |
+
)
|
77 |
+
select sum(st_length(geom::geography)) as road_length_florida
|
78 |
+
from tl_2023_us_primaryroads, state
|
79 |
+
where st_contains(state.state_geom, geom);
|
80 |
+
"
|
81 |
+
what percentage of the primary roads are in California?,"05-roads.txt,01-state.txt","with state as (
|
82 |
+
select geom as state_geom
|
83 |
+
from public.tl_2023_us_state
|
84 |
+
where name ilike '%california%'
|
85 |
+
limit 1
|
86 |
+
),
|
87 |
+
us_total as (
|
88 |
+
select count(*) as roads_in_us
|
89 |
+
from public.tl_2023_us_primaryroads
|
90 |
+
),
|
91 |
+
california_total as (
|
92 |
+
select count(public.tl_2023_us_primaryroads.gid) as roads_in_california
|
93 |
+
from public.tl_2023_us_primaryroads, state
|
94 |
+
where st_contains(state.state_geom, public.tl_2023_us_primaryroads.geom)
|
95 |
+
)
|
96 |
+
select (us_total.roads_in_us::float / california_total.roads_in_california::float) as percentage
|
97 |
+
from us_total, california_total"
|
98 |
+
in which state does I-77 highway lie?,"05-roads.txt,01-state.txt","with road as (
|
99 |
+
select geom as road_geom
|
100 |
+
from public.tl_2023_us_primaryroads tup
|
101 |
+
where fullname ilike '%I- 77%'
|
102 |
+
limit 1
|
103 |
+
)
|
104 |
+
select name
|
105 |
+
from public.tl_2023_us_state, road
|
106 |
+
where st_contains(geom, road.road_geom)
|
107 |
+
limit 1;"
|
108 |
+
which is the biggest metropolitan city in US?,04-metropolitan.txt,"select geoid, name, st_area(geom::geography) * 0.3048 ^ 2 as area_sqm
|
109 |
+
from public.tl_2023_us_cbsa
|
110 |
+
where lsad = 'M1'
|
111 |
+
order by st_area(geom::geography) desc
|
112 |
+
limit 1;"
|
113 |
+
What is the area of New York metropolitan city?,04-metropolitan.txt,"select geoid, name, st_area(geom::geography) * 0.3048 ^ 2 as area_sqm
|
114 |
+
from public.tl_2023_us_cbsa
|
115 |
+
where name ilike '%New York%';"
|
116 |
+
"Is the 8336 104th Ct, Vero Beach, FL 32967 located in a metropolitan statistical area?",04-metropolitan.txt,"with property as (
|
117 |
+
SELECT
|
118 |
+
ST_X(geomout) as lon,
|
119 |
+
ST_Y(geomout) as lat
|
120 |
+
from geocode('8336 104th Ct, Vero Beach, FL 32967')
|
121 |
+
limit 1
|
122 |
+
)
|
123 |
+
select geoid, name
|
124 |
+
from tl_2023_us_cbsa, property
|
125 |
+
where st_contains(geom, st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269));"
|
126 |
+
How many metropolitan statistical areas are in Florida state?,"04-metropolitan.txt,01-state.txt","with florida_state as (
|
127 |
+
select geom
|
128 |
+
from tl_2023_us_state
|
129 |
+
where name ilike '%florida%'
|
130 |
+
limit 1
|
131 |
+
)
|
132 |
+
select count(*) as num_metro_areas_florida
|
133 |
+
from tl_2023_us_cbsa, florida_state
|
134 |
+
where st_contains(florida_state.geom, tl_2023_us_cbsa.geom) and lsad = 'M1';"
|
135 |
+
"Which is the nearest metropolitan statistical area from the property located at 8336 104th Ct, Vero Beach, FL 32967?",04-metropolitan.txt,"with property as (
|
136 |
+
SELECT
|
137 |
+
ST_X(geomout) as lon,
|
138 |
+
ST_Y(geomout) as lat
|
139 |
+
from geocode('8336 104th Ct, Vero Beach, FL 32967')
|
140 |
+
limit 1
|
141 |
+
)
|
142 |
+
select name, geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography as dist
|
143 |
+
from public.tl_2023_us_cbsa, property
|
144 |
+
where tl_2023_us_cbsa.lsad = 'M1'
|
145 |
+
order by dist asc
|
146 |
+
limit 1;"
|
147 |
+
List 5 most biggest metropolitan areas in California.,"04-metropolitan.txt,01-state.txt","with cal_state as (
|
148 |
+
select geom
|
149 |
+
from tl_2023_us_state
|
150 |
+
where name ilike '%california%'
|
151 |
+
limit 1
|
152 |
+
)
|
153 |
+
select geoid, name, st_area(tl_2023_us_cbsa.geom::geography) * 0.3048 ^ 2 as area_sqm
|
154 |
+
from tl_2023_us_cbsa, cal_state
|
155 |
+
where st_contains(cal_state.geom, tl_2023_us_cbsa.geom) and lsad = 'M1'
|
156 |
+
order by st_area(tl_2023_us_cbsa.geom::geography) desc
|
157 |
+
limit 5;"
|
158 |
+
Where is New Haven metropolitan area located?,"04-metropolitan.txt,01-state.txt","with new_haven as (
|
159 |
+
select geom
|
160 |
+
from public.tl_2023_us_cbsa
|
161 |
+
where name ilike '%new haven%' and lsad = 'M1'
|
162 |
+
limit 1
|
163 |
+
)
|
164 |
+
select geoid, name
|
165 |
+
from tl_2023_us_state, new_haven
|
166 |
+
where st_contains(tl_2023_us_state.geom, new_haven.geom);"
|
167 |
+
Which state has the highest number of micropolitan areas?,"04-metropolitan.txt,01-state.txt","with state_to_micropolitan as (
|
168 |
+
select public.tl_2023_us_cbsa.name as micro_name,
|
169 |
+
public.tl_2023_us_cbsa.geom as micro_geom,
|
170 |
+
public.tl_2023_us_state.name as state_name,
|
171 |
+
public.tl_2023_us_state.geom as state_geom
|
172 |
+
from public.tl_2023_us_cbsa cross join public.tl_2023_us_state
|
173 |
+
where tl_2023_us_cbsa.lsad = 'M2'
|
174 |
+
)
|
175 |
+
select state_name, count(*) as n_micropolitans
|
176 |
+
from state_to_micropolitan
|
177 |
+
where st_contains(state_geom, micro_geom)
|
178 |
+
group by state_name
|
179 |
+
order by n_micropolitans desc
|
180 |
+
limit 1;"
|
181 |
+
Which state has the highest number of metropolitan areas?,"04-metropolitan.txt,01-state.txt","with state_to_metropolitan as (
|
182 |
+
select public.tl_2023_us_cbsa.name as metro_name,
|
183 |
+
public.tl_2023_us_cbsa.geom as metro_geom,
|
184 |
+
public.tl_2023_us_state.name as state_name,
|
185 |
+
public.tl_2023_us_state.geom as state_geom
|
186 |
+
from public.tl_2023_us_cbsa cross join public.tl_2023_us_state
|
187 |
+
where tl_2023_us_cbsa.lsad = 'M1'
|
188 |
+
)
|
189 |
+
select state_name, count(*) as n_metropolitans
|
190 |
+
from state_to_metropolitan
|
191 |
+
where st_contains(state_geom, metro_geom)
|
192 |
+
group by state_name
|
193 |
+
order by n_metropolitans desc
|
194 |
+
limit 1;"
|
195 |
+
"How far is the property at 8336 104th Ct, Vero Beach, FL 32967 from a major metropolitan city in US?",04-metropolitan.txt,"with property as (
|
196 |
+
SELECT
|
197 |
+
ST_X(geomout) as lon,
|
198 |
+
ST_Y(geomout) as lat
|
199 |
+
from geocode('8336 104th Ct, Vero Beach, FL 32967')
|
200 |
+
limit 1
|
201 |
+
)
|
202 |
+
select name, geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography as dist
|
203 |
+
from public.tl_2023_us_cbsa, property
|
204 |
+
where tl_2023_us_cbsa.lsad = 'M1'
|
205 |
+
order by dist asc
|
206 |
+
limit 1;"
|
207 |
+
List out all the metropolitan and micropolitan areas in the state of California.,"04-metropolitan.txt,01-state.txt","
|
208 |
+
with cal_state as (
|
209 |
+
select geom
|
210 |
+
from tl_2023_us_state
|
211 |
+
where name ilike '%california%'
|
212 |
+
limit 1
|
213 |
+
)
|
214 |
+
select geoid, name, lsad
|
215 |
+
from tl_2023_us_cbsa, cal_state
|
216 |
+
where st_contains(cal_state.geom, tl_2023_us_cbsa.geom);"
|
217 |
+
List out all the primary roads that pass through Mansfield Metropolitan Area.,"04-metropolitan.txt,05-roads.txt","with mansfield_metro as (
|
218 |
+
select name, geom
|
219 |
+
from tl_2023_us_cbsa
|
220 |
+
where name ilike '%mansfield%' and lsad = 'M1'
|
221 |
+
limit 1
|
222 |
+
)
|
223 |
+
select tl_2023_us_primaryroads.fullname
|
224 |
+
from public.tl_2023_us_primaryroads, mansfield_metro
|
225 |
+
where st_intersects(mansfield_metro.geom, tl_2023_us_primaryroads.geom)"
|
226 |
+
How many primary roads pass through Mansfield Metropolitan area.,"04-metropolitan.txt,05-roads.txt","with mansfield_metro as (
|
227 |
+
select name, geom
|
228 |
+
from tl_2023_us_cbsa
|
229 |
+
where name ilike '%mansfield%' and lsad = 'M1'
|
230 |
+
limit 1
|
231 |
+
)
|
232 |
+
select count(distinct tl_2023_us_primaryroads.fullname) as n_primaryroads
|
233 |
+
from public.tl_2023_us_primaryroads, mansfield_metro
|
234 |
+
where st_intersects(mansfield_metro.geom, tl_2023_us_primaryroads.geom);"
|
235 |
+
Which is the smallest metropolitan area in US?,04-metropolitan.txt,"select geoid, name, st_area(tl_2023_us_cbsa.geom::geography) * 0.3048 ^ 2 as area_sqm
|
236 |
+
from public.tl_2023_us_cbsa
|
237 |
+
where lsad = 'M1'
|
238 |
+
order by st_area(tl_2023_us_cbsa.geom::geography) asc
|
239 |
+
limit 1;"
|
240 |
+
Which county has the highest number of micropolitan areas?,"04-metropolitan.txt,02-county.txt","with county_to_micropolitan as (
|
241 |
+
select public.tl_2023_us_cbsa.name as micro_name,
|
242 |
+
public.tl_2023_us_cbsa.geom as micro_geom,
|
243 |
+
public.tl_2023_us_county.name as county_name,
|
244 |
+
public.tl_2023_us_county.geom as county_geom
|
245 |
+
from public.tl_2023_us_cbsa cross join public.tl_2023_us_county
|
246 |
+
where tl_2023_us_cbsa.lsad = 'M2'
|
247 |
+
)
|
248 |
+
select county_name, count(*) as n_micropolitans
|
249 |
+
from county_to_micropolitan
|
250 |
+
where st_contains(county_geom, micro_geom)
|
251 |
+
group by county_name
|
252 |
+
order by n_micropolitans desc
|
253 |
+
limit 1;"
|
254 |
+
What is the total count of metropolitan areas in US?,04-metropolitan.txt,"select count(*) as n_metropolitans
|
255 |
+
from tl_2023_us_cbsa
|
256 |
+
where lsad = 'M1';"
|
257 |
+
Provide me a list of US states with its metropolitan areas count.,"04-metropolitan.txt,01-state.txt","with state_to_metropolitan as (
|
258 |
+
select public.tl_2023_us_cbsa.name as metro_name,
|
259 |
+
public.tl_2023_us_cbsa.geom as metro_geom,
|
260 |
+
public.tl_2023_us_state.name as state_name,
|
261 |
+
public.tl_2023_us_state.geom as state_geom
|
262 |
+
from public.tl_2023_us_cbsa cross join public.tl_2023_us_state
|
263 |
+
where tl_2023_us_cbsa.lsad = 'M1'
|
264 |
+
)
|
265 |
+
select state_name, count(*)
|
266 |
+
from state_to_metropolitan
|
267 |
+
where st_contains(state_geom, metro_geom)
|
268 |
+
group by state_name;"
|
269 |
+
What is the total count of micropolitan areas in US?,04-metropolitan.txt,"select count(*) as n_micropolitans
|
270 |
+
from tl_2023_us_cbsa
|
271 |
+
where lsad = 'M2';"
|
272 |
+
Which is the smallest metropolitan area in Florida?,04-metropolitan.txt,"select geoid, name
|
273 |
+
from tl_2023_us_cbsa
|
274 |
+
where lsad = 'M1'
|
275 |
+
order by st_area(geom::geography) asc
|
276 |
+
limit 1;"
|
277 |
+
Which are the closest metropolitan cities in Florida?,04-metropolitan.txt,"with florida as (
|
278 |
+
select name, geom
|
279 |
+
from tl_2023_us_state
|
280 |
+
where name ilike '%florida%'
|
281 |
+
limit 1
|
282 |
+
)
|
283 |
+
select t1.name as area_1, t2.name as area_2, t1.geom::geography <-> t2.geom::geography as distance
|
284 |
+
from tl_2023_us_cbsa as t1 cross join tl_2023_us_cbsa as t2, florida
|
285 |
+
where t1.lsad = 'M1' and t2.lsad = 'M1' and st_contains(florida.geom, t1.geom) and st_contains(florida.geom, t2.geom)
|
286 |
+
and t1.geoid <> t2.geoid
|
287 |
+
order by t1.geom <-> t2.geom asc
|
288 |
+
limit 5;"
|
289 |
+
What are the neighboring states of Florida?,01-state.txt,"with florida as (
|
290 |
+
select name, geom
|
291 |
+
from tl_2023_us_state
|
292 |
+
where name ilike '%florida%'
|
293 |
+
limit 1
|
294 |
+
)
|
295 |
+
select tl_2023_us_state.name
|
296 |
+
from public.tl_2023_us_state, florida
|
297 |
+
where st_intersects(florida.geom, tl_2023_us_state.geom) and florida.name <> tl_2023_us_state.name;"
|
298 |
+
What is the area of Florida state?,01-state.txt,"select name, st_area(geom::geography) * 0.3048 ^ 2 as area_sqm
|
299 |
+
from tl_2023_us_state
|
300 |
+
where name ilike '%florida%';"
|
301 |
+
Give me a list of 5 biggest US states.,01-state.txt,"select name, st_area(geom::geography) * 0.3048 ^ 2 as area_sqm
|
302 |
+
from tl_2023_us_state
|
303 |
+
order by st_area(geom::geography) desc
|
304 |
+
limit 5;"
|
305 |
+
Which state has the highest water-to-total-area ratio?,01-state.txt,"select name
|
306 |
+
from tl_2023_us_state
|
307 |
+
order by awater / aland desc
|
308 |
+
limit 1;"
|
309 |
+
What is the average distance between the states of Michigan and North Dakota?,01-state.txt,"select st_distance(s1.geom, s2.geom) as distance
|
310 |
+
from tl_2023_us_state as s1 cross join tl_2023_us_state as s2
|
311 |
+
where s1.name ilike '%michigan%' and s2.name ilike '%north dakota%'
|
312 |
+
limit 1;"
|
313 |
+
Provide me a list of US states with count of primary roads it has.,"01-state.txt,05-roads.txt","select states.name as state_name, count(distinct roads.fullname)
|
314 |
+
from tl_2023_us_state as states cross join tl_2023_us_primaryroads as roads
|
315 |
+
where st_contains(states.geom, roads.geom)
|
316 |
+
group by state_name;"
|
317 |
+
Which state has the highest number of counties?,"01-state.txt,02-county.txt","select states.name as state_name, count(distinct counties.name) as n_counties
|
318 |
+
from tl_2023_us_state as states cross join tl_2023_us_county as counties
|
319 |
+
where st_contains(states.geom, counties.geom)
|
320 |
+
group by state_name
|
321 |
+
order by n_counties desc
|
322 |
+
limit 1;"
|
323 |
+
List out 10 nearest states from New York.,01-state.txt,"with newyork as (
|
324 |
+
select geoid, geom
|
325 |
+
from tl_2023_us_state
|
326 |
+
where name ilike '%new york%'
|
327 |
+
limit 1
|
328 |
+
)
|
329 |
+
select name
|
330 |
+
from tl_2023_us_state, newyork
|
331 |
+
where newyork.geoid <> tl_2023_us_state.geoid
|
332 |
+
order by tl_2023_us_state.geom <-> newyork.geom asc
|
333 |
+
limit 10;"
|
334 |
+
"Which US state contains the coordinates 19.2, -155.4?",01-state.txt,"select name
|
335 |
+
from tl_2023_us_state
|
336 |
+
where st_contains(geom, st_transform(st_setsrid(st_point(-155.4, 19.2), 4326),4269))
|
337 |
+
limit 1;"
|
338 |
+
Which state is Andrews County located in?,"01-state.txt,02-county.txt","with andrews as (
|
339 |
+
select geom
|
340 |
+
from tl_2023_us_county
|
341 |
+
where name ilike '%andrews%'
|
342 |
+
limit 1
|
343 |
+
)
|
344 |
+
select name
|
345 |
+
from tl_2023_us_state, andrews
|
346 |
+
where st_contains(tl_2023_us_state.geom, andrews.geom)
|
347 |
+
limit 1;"
|
348 |
+
What are the neighboring counties of Andrews County?,02-county.txt,"with andrews as (
|
349 |
+
select geoid, geom
|
350 |
+
from tl_2023_us_county
|
351 |
+
where name ilike '%andrews%'
|
352 |
+
limit 1
|
353 |
+
)
|
354 |
+
select name
|
355 |
+
from tl_2023_us_county, andrews
|
356 |
+
where st_intersects(tl_2023_us_county.geom, andrews.geom) and andrews.geoid <> tl_2023_us_county.geoid;"
|
357 |
+
Which county has the highest water-to-total-area ratio?,02-county.txt,"select name
|
358 |
+
from tl_2023_us_county
|
359 |
+
order by awater / aland desc
|
360 |
+
limit 1;"
|
361 |
+
Provide me a list of US states with total number of counties it has.,"01-state.txt,02-county.txt","select state.name as state_name, count(distinct county.name) as county_name
|
362 |
+
from tl_2023_us_state as state cross join tl_2023_us_county as county
|
363 |
+
where st_contains(state.geom, county.geom)
|
364 |
+
group by state_name;"
|
365 |
+
Which is the third largest county in United States?,02-county.txt,"select name
|
366 |
+
from tl_2023_us_county
|
367 |
+
order by st_area(geom) desc
|
368 |
+
limit 1 offset 2;"
|
369 |
+
Which is the largest county that also has a metropolitan area?,"02-county.txt,04-metropolitan.txt","select county.name, st_area(county.geom)
|
370 |
+
from tl_2023_us_county as county cross join tl_2023_us_cbsa as metro
|
371 |
+
where metro.lsad = 'M1' and st_contains(county.geom, metro.geom)
|
372 |
+
order by st_area(county.geom) desc
|
373 |
+
limit 1;"
|
374 |
+
How many primary roads does Andrews County have?,"02-county.txt,05-roads.txt","with andrews as (
|
375 |
+
select geoid, geom
|
376 |
+
from tl_2023_us_county
|
377 |
+
where name ilike '%andrews%'
|
378 |
+
limit 1
|
379 |
+
)
|
380 |
+
select count(distinct fullname)
|
381 |
+
from tl_2023_us_primaryroads, andrews
|
382 |
+
where st_contains(andrews.geom, tl_2023_us_primaryroads.geom);
|
383 |
+
"
|
384 |
+
"Which county is the property 8336 104th Ct, Vero Beach, FL 32967 located in?",02-county.txt,"with property as (
|
385 |
+
SELECT
|
386 |
+
ST_X(geomout) as lon,
|
387 |
+
ST_Y(geomout) as lat
|
388 |
+
from geocode('8336 104th Ct, Vero Beach, FL 32967')
|
389 |
+
limit 1
|
390 |
+
)
|
391 |
+
select name
|
392 |
+
from property, tl_2023_us_county
|
393 |
+
where st_contains(tl_2023_us_county.geom, st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269));"
|
394 |
+
"List out 5 neighboring counties of the county where property at 8336 104th Ct, Vero Beach, FL 32967 is located?",02-county.txt,"with property as (
|
395 |
+
SELECT
|
396 |
+
ST_X(geomout) as lon,
|
397 |
+
ST_Y(geomout) as lat
|
398 |
+
from geocode('8336 104th Ct, Vero Beach, FL 32967')
|
399 |
+
limit 1
|
400 |
+
)
|
401 |
+
select name
|
402 |
+
from property, public.tl_2023_us_county
|
403 |
+
order by tl_2023_us_county.geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269) asc
|
404 |
+
limit 5 offset 1;"
|
405 |
+
Which is the smallest county in Michigan?,"01-state.txt,02-county.txt","with michigan as (
|
406 |
+
select geoid, geom
|
407 |
+
from tl_2023_us_state
|
408 |
+
where name ilike '%michigan%'
|
409 |
+
limit 1
|
410 |
+
)
|
411 |
+
select tl_2023_us_county.name
|
412 |
+
from michigan, tl_2023_us_county
|
413 |
+
where st_contains(michigan.geom, tl_2023_us_county.geom)
|
414 |
+
order by st_area(tl_2023_us_county.geom) asc
|
415 |
+
limit 1;"
|
416 |
+
40. How many counties are there in California state and what are they?,"01-state.txt,02-county.txt","with california as (
|
417 |
+
select geoid, geom
|
418 |
+
from tl_2023_us_state
|
419 |
+
where name ilike '%california%'
|
420 |
+
limit 1
|
421 |
+
)
|
422 |
+
select count(distinct county.name) as n_counties
|
423 |
+
from california, tl_2023_us_county as county
|
424 |
+
where st_contains(california.geom, county.geom);"
|
425 |
+
What is the total length of coastline in Florida?,"01-state.txt,03-coastline.txt","with florida as (
|
426 |
+
select geoid, geom
|
427 |
+
from tl_2023_us_state
|
428 |
+
where name ilike '%florida%'
|
429 |
+
limit 1
|
430 |
+
)
|
431 |
+
select sum(st_length(coastline.geom::geography))/1000 as total_length_km
|
432 |
+
from florida, tl_2023_us_coastline as coastline
|
433 |
+
where st_intersects(florida.geom, coastline.geom);"
|
434 |
+
Which state has the longest coastline?,"01-state.txt,03-coastline.txt","select state.name, sum(st_length(coastline.geom::geography))/1000 as coastline_len_km
|
435 |
+
from tl_2023_us_state as state cross join tl_2023_us_coastline as coastline
|
436 |
+
where st_intersects(state.geom, coastline.geom)
|
437 |
+
group by state.name
|
438 |
+
order by sum(st_length(coastline.geom::geography)) desc
|
439 |
+
limit 1;"
|
440 |
+
Which is the longest coastline in Florida?,"01-state.txt,02-county.txt,03-coastline.txt","with florida as (
|
441 |
+
select geoid, geom
|
442 |
+
from tl_2023_us_state
|
443 |
+
where name ilike '%florida%'
|
444 |
+
limit 1
|
445 |
+
)
|
446 |
+
select coastline.name, sum(st_length(coastline.geom::geography))/1000 as length_km
|
447 |
+
from florida, public.tl_2023_us_coastline as coastline
|
448 |
+
where st_contains(florida.geom, coastline.geom)
|
449 |
+
group by coastline.name
|
450 |
+
order by length_km desc
|
451 |
+
limit 1;"
|
452 |
+
List out counties in Florida are exposed to a sea/ocean.,"01-state.txt,03-coastline.txt","with florida as (
|
453 |
+
select geoid, geom
|
454 |
+
from tl_2023_us_state
|
455 |
+
where name ilike '%florida%'
|
456 |
+
limit 1
|
457 |
+
)
|
458 |
+
select county.name, count(distinct coastline.name)
|
459 |
+
from public.tl_2023_us_county as county cross join public.tl_2023_us_coastline as coastline, florida
|
460 |
+
where st_intersects(county.geom, coastline.geom) and st_contains(florida.geom, county.geom)
|
461 |
+
group by county.name;"
|
462 |
+
How many US states are exposed to a sea/ocean?,"01-state.txt,03-coastline.txt","select state.name
|
463 |
+
from tl_2023_us_state as state cross join tl_2023_us_coastline as coastline
|
464 |
+
where st_intersects(state.geom, coastline.geom)
|
465 |
+
group by state.name;"
|
466 |
+
How many US counties are exposed to sea?,"02-county.txt,03-coastline.txt","select count(distinct county.name)
|
467 |
+
from tl_2023_us_county as county cross join tl_2023_us_coastline as coastline
|
468 |
+
where st_intersects(county.geom, coastline.geom);"
|
469 |
+
Which is the largest landlocked state in US?,"01-state.txt,03-coastline.txt","with states_with_coastline as (
|
470 |
+
select distinct state.name
|
471 |
+
from tl_2023_us_state as state cross join tl_2023_us_coastline as coastline
|
472 |
+
where st_contains(state.geom, coastline.geom)
|
473 |
+
)
|
474 |
+
select state.name, st_area(state.geom::geography)
|
475 |
+
from tl_2023_us_state as state, states_with_coastline
|
476 |
+
where state.name not in (select name from states_with_coastline)
|
477 |
+
order by st_area(state.geom) desc
|
478 |
+
limit 1;"
|
479 |
+
Which is the largest landlocked county in US?,"02-county.txt,03-coastline.txt","with county_with_coastline as (
|
480 |
+
select distinct county.name
|
481 |
+
from tl_2023_us_county as county cross join tl_2023_us_coastline as coastline
|
482 |
+
where st_contains(county.geom, coastline.geom)
|
483 |
+
)
|
484 |
+
select county.name, st_area(county.geom::geography)
|
485 |
+
from tl_2023_us_county as county, county_with_coastline
|
486 |
+
where county.name not in (select name from county_with_coastline)
|
487 |
+
order by st_area(county.geom) desc
|
488 |
+
limit 1;"
|
489 |
+
Which is the name of longest coastline in US?,03-coastline.txt,"select name, sum(st_length(geom::geography)) as tot_length
|
490 |
+
from tl_2023_us_coastline
|
491 |
+
group by name
|
492 |
+
order by tot_length desc
|
493 |
+
limit 1;"
|
494 |
+
Which is the shortest coastline in US?,03-coastline.txt,"select name, sum(st_length(geom::geography)) as tot_length
|
495 |
+
from tl_2023_us_coastline
|
496 |
+
group by name
|
497 |
+
order by tot_length asc
|
498 |
+
limit 1;"
|
499 |
+
Which is the longest coastline in New York?,"01-state.txt,03-coastline.txt","with new_york as (
|
500 |
+
select geoid, geom
|
501 |
+
from tl_2023_us_state
|
502 |
+
where name ilike '%new york%'
|
503 |
+
limit 1
|
504 |
+
)
|
505 |
+
select coastline.name, sum(st_length(coastline.geom::geography)) as length_meter
|
506 |
+
from tl_2023_us_coastline as coastline, new_york
|
507 |
+
where st_intersects(new_york.geom, coastline.geom)
|
508 |
+
group by coastline.name
|
509 |
+
order by length_meter desc
|
510 |
+
limit 1;"
|
511 |
+
What states do the longest coastline in US belong to?,"01-state.txt,03-coastline.txt","with longest_coastline as (
|
512 |
+
select name, sum(st_length(geom::geography)) as total_length, st_collect(geom) as geom
|
513 |
+
from tl_2023_us_coastline
|
514 |
+
group by name
|
515 |
+
order by total_length
|
516 |
+
limit 1
|
517 |
+
)
|
518 |
+
select state.name
|
519 |
+
from longest_coastline, tl_2023_us_state as state
|
520 |
+
where st_intersects(longest_coastline.geom, state.geom);"
|
521 |
+
What is the length of shortest coastline in California?,"01-state.txt,03-coastline.txt","with california as (
|
522 |
+
select geoid, geom
|
523 |
+
from tl_2023_us_state
|
524 |
+
where name ilike '%california%'
|
525 |
+
limit 1
|
526 |
+
)
|
527 |
+
select coastline.name, sum(st_length(coastline.geom::geography))/1000 as length_km
|
528 |
+
from tl_2023_us_coastline as coastline, california
|
529 |
+
where st_intersects(california.geom, coastline.geom)
|
530 |
+
group by coastline.name
|
531 |
+
order by sum(st_length(coastline.geom::geography)) asc
|
532 |
+
limit 1;"
|
533 |
+
What is the length of longest coastline in California?,"01-state.txt,03-coastline.txt","with california as (
|
534 |
+
select geoid, geom
|
535 |
+
from tl_2023_us_state
|
536 |
+
where name ilike '%california%'
|
537 |
+
limit 1
|
538 |
+
)
|
539 |
+
select coastline.name, sum(st_length(coastline.geom::geography))/1000 as length_km
|
540 |
+
from tl_2023_us_coastline as coastline, california
|
541 |
+
where st_intersects(california.geom, coastline.geom)
|
542 |
+
group by coastline.name
|
543 |
+
order by sum(st_length(coastline.geom::geography)) desc
|
544 |
+
limit 1;"
|
545 |
+
What is the average length of a coastline in US?,03-coastline.txt,"with coastlines as (
|
546 |
+
select coastline.name, sum(st_length(coastline.geom::geography))/1000 as length_km
|
547 |
+
from tl_2023_us_coastline as coastline
|
548 |
+
group by coastline.name
|
549 |
+
)
|
550 |
+
select avg(coastlines.avg_length_km)
|
551 |
+
from coastlines;"
|
552 |
+
What is the average length of a coastline in Florida?,"01-state.txt,03-coastline.txt","with florida as (
|
553 |
+
select geoid, geom
|
554 |
+
from tl_2023_us_state
|
555 |
+
where name ilike '%florida%'
|
556 |
+
limit 1
|
557 |
+
),
|
558 |
+
coastlines as (
|
559 |
+
select coastline.name, sum(st_length(coastline.geom::geography))/1000 as length_km
|
560 |
+
from tl_2023_us_coastline as coastline, florida
|
561 |
+
where st_intersects(florida.geom, coastline.geom)
|
562 |
+
group by coastline.name
|
563 |
+
)
|
564 |
+
select avg(coastlines.length_km)
|
565 |
+
from coastlines;"
|
566 |
+
"How far is the nearest coastline from the property located at 8336 104th Ct, Vero Beach, FL 32967?",,"with property as (
|
567 |
+
SELECT
|
568 |
+
ST_X(geomout) as lon,
|
569 |
+
ST_Y(geomout) as lat
|
570 |
+
from geocode('8336 104th Ct, Vero Beach, FL 32967')
|
571 |
+
limit 1
|
572 |
+
)
|
573 |
+
select coastline.name, (geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography) / 1000 as dist_km
|
574 |
+
from property, tl_2023_us_coastline as coastline
|
575 |
+
order by dist_km asc
|
576 |
+
limit 1;"
|
577 |
+
"Is there any coastline within 1000 km radius of the location 8336 104th Ct, Vero Beach, FL 32967?",03-coastline.txt,"with property as (
|
578 |
+
SELECT
|
579 |
+
ST_X(geomout) as lon,
|
580 |
+
ST_Y(geomout) as lat
|
581 |
+
from geocode('8336 104th Ct, Vero Beach, FL 32967')
|
582 |
+
limit 1
|
583 |
+
)
|
584 |
+
select coastline.name, (geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography) / 1000 as dist_km
|
585 |
+
from property, tl_2023_us_coastline as coastline
|
586 |
+
order by dist_km asc
|
587 |
+
limit 1;"
|
588 |
+
How far is the nearest coastline from the state of Nevada?,"01-state.txt,03-coastline.txt","with nevada as (
|
589 |
+
select geoid, geom
|
590 |
+
from tl_2023_us_state
|
591 |
+
where name ilike '%nevada%'
|
592 |
+
limit 1
|
593 |
+
)
|
594 |
+
select coastline.name, (nevada.geom <-> coastline.geom) / 1000 as dist_km
|
595 |
+
from nevada, tl_2023_us_coastline as coastline
|
596 |
+
order by dist_km asc
|
597 |
+
limit 1;"
|
598 |
+
Where is Stone Ranch military resident located?,"01-state.txt,06-military.txt","with stone_ranch as (
|
599 |
+
select geom
|
600 |
+
from tl_2023_us_mil
|
601 |
+
where fullname ilike '%stone ranch%'
|
602 |
+
limit 1
|
603 |
+
)
|
604 |
+
select name
|
605 |
+
from tl_2023_us_state as state, stone_ranch
|
606 |
+
where st_contains(state.geom, stone_ranch.geom);"
|
607 |
+
Which state has the highest no of military residential areas?,"01-state.txt,06-military.txt","select state.name, count(military_areas.fullname) as num_military_areas
|
608 |
+
from tl_2023_us_state as state cross join tl_2023_us_mil as military_areas
|
609 |
+
where st_contains(state.geom, military_areas.geom)
|
610 |
+
group by state.name
|
611 |
+
order by num_military_areas desc
|
612 |
+
limit 1;"
|
613 |
+
Which is the largest military installation area?,06-military.txt,"select fullname
|
614 |
+
from tl_2023_us_mil
|
615 |
+
order by st_area(geom)
|
616 |
+
limit 1;"
|
617 |
+
How many military installation areas are present in California?,"01-state.txt,06-military.txt","with california as (
|
618 |
+
select geoid, geom
|
619 |
+
from tl_2023_us_state
|
620 |
+
where name ilike '%california%'
|
621 |
+
limit 1
|
622 |
+
)
|
623 |
+
select count(fullname) as num_military_areas
|
624 |
+
from public.tl_2023_us_mil as military_areas, california
|
625 |
+
where st_contains(california.geom, military_areas.geom);"
|
626 |
+
Which county has the highest number of military installations?,"02-county.txt,06-military.txt","select county.name, count(military_areas.fullname) as num_military_areas
|
627 |
+
from tl_2023_us_county as county cross join tl_2023_us_mil as military_areas
|
628 |
+
where st_contains(county.geom, military_areas.geom)
|
629 |
+
group by county.name
|
630 |
+
order by num_military_areas desc
|
631 |
+
limit 1;"
|
632 |
+
Provide me a list of all military installations in California with their areas.,"01-state.txt,06-military.txt","with california as (
|
633 |
+
select geoid, geom
|
634 |
+
from tl_2023_us_state
|
635 |
+
where name ilike '%california%'
|
636 |
+
limit 1
|
637 |
+
)
|
638 |
+
select military_areas.fullname, st_area(military_areas.geom::geography) * 0.3048 ^ 2 as area_sqm
|
639 |
+
from public.tl_2023_us_mil as military_areas, california
|
640 |
+
where st_contains(california.geom, military_areas.geom);"
|
641 |
+
Which is the smallest military installation in US?,06-military.txt,"select fullname, st_area(geom::geography) * 0.3048 ^ 2 as area_sqm
|
642 |
+
from tl_2023_us_mil
|
643 |
+
order by st_area(geom) asc
|
644 |
+
limit 1;"
|
645 |
+
"How far is the nearest military installation from 8336 104th Ct, Vero Beach, FL 32967?",06-military.txt,"with property as (
|
646 |
+
SELECT
|
647 |
+
ST_X(geomout) as lon,
|
648 |
+
ST_Y(geomout) as lat
|
649 |
+
from geocode('8336 104th Ct, Vero Beach, FL 32967')
|
650 |
+
limit 1
|
651 |
+
)
|
652 |
+
select fullname, military_areas.geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography as dist
|
653 |
+
from property, public.tl_2023_us_mil as military_areas
|
654 |
+
order by dist asc
|
655 |
+
limit 1;"
|
656 |
+
"Are there any military installation within 1000km radius of 8336 104th Ct, Vero Beach, FL 32967?",06-military.txt,"with property as (
|
657 |
+
SELECT
|
658 |
+
ST_X(geomout) as lon,
|
659 |
+
ST_Y(geomout) as lat
|
660 |
+
from geocode('8336 104th Ct, Vero Beach, FL 32967')
|
661 |
+
limit 1
|
662 |
+
)
|
663 |
+
select fullname, (military_areas.geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography)/1000 as dist_km
|
664 |
+
from property, public.tl_2023_us_mil as military_areas
|
665 |
+
order by dist_km asc
|
666 |
+
limit 1;"
|
667 |
+
Which military installation has the highest water area occupancy?,06-military.txt,"select fullname
|
668 |
+
from tl_2023_us_mil
|
669 |
+
order by awater desc
|
670 |
+
limit 1;"
|
671 |
+
What percentage of military installations are purely based on land?,06-military.txt,"with all_military as (
|
672 |
+
select count(*) as total_areas
|
673 |
+
from tl_2023_us_mil
|
674 |
+
),
|
675 |
+
land_military as (
|
676 |
+
select count(*) as total_land
|
677 |
+
from tl_2023_us_mil
|
678 |
+
where awater = 0
|
679 |
+
)
|
680 |
+
select land_military.total_land::float / all_military.total_areas::float as percent_military
|
681 |
+
from all_military, land_military;"
|
682 |
+
Which county is Ft Riley located in?,"02-county.txt,06-military.txt","with fort_riley as (
|
683 |
+
select geom
|
684 |
+
from tl_2023_us_mil
|
685 |
+
where fullname ilike '%fort riley%'
|
686 |
+
limit 1
|
687 |
+
)
|
688 |
+
select county.name
|
689 |
+
from public.tl_2023_us_county as county, fort_riley
|
690 |
+
where st_contains(county.geom, fort_riley.geom);"
|
691 |
+
Which military installation is the largest in Washington?,"01-state.txt,06-military.txt","with washington as (
|
692 |
+
select geoid, geom
|
693 |
+
from tl_2023_us_state
|
694 |
+
where name ilike '%washington%'
|
695 |
+
limit 1
|
696 |
+
)
|
697 |
+
select fullname
|
698 |
+
from public.tl_2023_us_mil
|
699 |
+
order by st_area(geom) desc
|
700 |
+
limit 1;"
|
701 |
+
Which state has the least number of military installations?,"01-state.txt,06-military.txt","select state.name, count(military.fullname) as num_military_installations
|
702 |
+
from tl_2023_us_state as state cross join tl_2023_us_mil as military
|
703 |
+
where st_contains(state.geom, military.geom)
|
704 |
+
group by state.name
|
705 |
+
order by num_military_installations asc
|
706 |
+
limit 1;"
|
707 |
+
List 5 states with most no of military installations?,"01-state.txt,06-military.txt","select state.name, count(military.fullname) as num_military_installations
|
708 |
+
from tl_2023_us_state as state cross join tl_2023_us_mil as military
|
709 |
+
where st_contains(state.geom, military.geom)
|
710 |
+
group by state.name
|
711 |
+
order by num_military_installations desc
|
712 |
+
limit 5;"
|
713 |
+
How many naval stations are there in Florida?,"01-state.txt,06-military.txt","with florida as (
|
714 |
+
select geoid, geom
|
715 |
+
from tl_2023_us_state
|
716 |
+
where name ilike '%florida%'
|
717 |
+
limit 1
|
718 |
+
)
|
719 |
+
select count(*) as num_naval_stations
|
720 |
+
from florida, public.tl_2023_us_mil as military
|
721 |
+
where fullname ilike '%naval%' and st_contains(florida.geom, military.geom);
|
722 |
+
"
|
723 |
+
How many naval stations are there in entire US?,06-military.txt,"select count(*) as num_naval_stations
|
724 |
+
from public.tl_2023_us_mil as military
|
725 |
+
where fullname ilike '%naval%';"
|
726 |
+
"Are there any coast guard station near 8336 104th Ct, Vero Beach, FL 32967?",06-military.txt,"with property as (
|
727 |
+
SELECT
|
728 |
+
ST_X(geomout) as lon,
|
729 |
+
ST_Y(geomout) as lat
|
730 |
+
from geocode('8336 104th Ct, Vero Beach, FL 32967')
|
731 |
+
limit 1
|
732 |
+
)
|
733 |
+
select tl_2023_us_mil.fullname, (tl_2023_us_mil.geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography)/1000 as dist_km
|
734 |
+
from property, public.tl_2023_us_mil
|
735 |
+
where fullname ilike '%coast guard%'
|
736 |
+
order by dist_km asc;"
|
737 |
+
How many coast guard station are present in Florida?,"01-state.txt,06-military.txt","with florida as (
|
738 |
+
select geoid, geom
|
739 |
+
from tl_2023_us_state
|
740 |
+
where name ilike '%florida%'
|
741 |
+
limit 1
|
742 |
+
)
|
743 |
+
select count(distinct fullname)
|
744 |
+
from florida, public.tl_2023_us_mil
|
745 |
+
where st_contains(florida.geom, tl_2023_us_mil.geom) and fullname ilike '%coast guard%';"
|
746 |
+
Which state has the most no of railways?,"01-state.txt,06-military.txt","select state.name as state_name, count(railways.gid) as num_railways
|
747 |
+
from tl_2023_us_state as state cross join tl_2023_us_rails as railways
|
748 |
+
where st_contains(state.geom, railways.geom)
|
749 |
+
group by state.name
|
750 |
+
order by num_railways desc
|
751 |
+
limit 1;"
|
752 |
+
Which is the longest railway in US?,07-railways.txt,"select fullname, sum(st_length(geom::geography))/1000 as length_km
|
753 |
+
from tl_2023_us_rails as railways
|
754 |
+
where fullname is not null
|
755 |
+
group by fullname
|
756 |
+
order by length_km desc
|
757 |
+
limit 1;"
|
758 |
+
Which is the longest railway in Florida?,"01-state.txt,07-railways.txt","with florida as (
|
759 |
+
select geoid, geom
|
760 |
+
from tl_2023_us_state
|
761 |
+
where name ilike '%florida%'
|
762 |
+
limit 1
|
763 |
+
)
|
764 |
+
select railways.fullname, sum(st_length(railways.geom::geography))/1000 as length_km
|
765 |
+
from tl_2023_us_rails as railways, florida
|
766 |
+
where fullname is not null and st_intersects(florida.geom, railways.geom)
|
767 |
+
group by fullname
|
768 |
+
order by length_km desc
|
769 |
+
limit 1;"
|
770 |
+
Which is the shortest railway in US?,07-railways.txt,"select fullname, sum(st_length(geom::geography))/1000 as length_km
|
771 |
+
from tl_2023_us_rails as railways
|
772 |
+
where fullname is not null
|
773 |
+
group by fullname
|
774 |
+
order by length_km asc
|
775 |
+
limit 1;"
|
776 |
+
"Are there any railways within 1000km radius of 8336 104th Ct, Vero Beach, FL 32967?",07-railways.txt,"with property as (
|
777 |
+
SELECT
|
778 |
+
ST_X(geomout) as lon,
|
779 |
+
ST_Y(geomout) as lat
|
780 |
+
from geocode('8336 104th Ct, Vero Beach, FL 32967')
|
781 |
+
limit 1
|
782 |
+
),
|
783 |
+
near_railways as (
|
784 |
+
select railways.fullname, sum(railways.geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography)/1000 as dist_km
|
785 |
+
from property, tl_2023_us_rails as railways
|
786 |
+
group by railways.fullname
|
787 |
+
order by dist_km asc
|
788 |
+
)
|
789 |
+
select fullname
|
790 |
+
from near_railways
|
791 |
+
where near_railways.dist_km < 1000;"
|
792 |
+
What is the average length of a railway in United States?,07-railways.txt,"with total_lengths as (
|
793 |
+
select fullname, sum(st_length(geom::geography)/1000) as total_length
|
794 |
+
from tl_2023_us_rails as railways
|
795 |
+
where fullname is not null
|
796 |
+
group by fullname
|
797 |
+
)
|
798 |
+
select avg(total_lengths.total_length)
|
799 |
+
from total_lengths;"
|
800 |
+
What is the length of Illinois Central railway?,07-railways.txt,"select sum(st_length(geom::geography))/1000 as length_km
|
801 |
+
from tl_2023_us_rails
|
802 |
+
where fullname ilike '%illinois central';"
|
803 |
+
How many railways are there in Michigan?,"01-state.txt,07-railways.txt","with michigan as (
|
804 |
+
select geom
|
805 |
+
from tl_2023_us_state
|
806 |
+
where name ilike '%michigan%'
|
807 |
+
limit 1
|
808 |
+
),
|
809 |
+
michigan_railways as (
|
810 |
+
select railways.fullname
|
811 |
+
from michigan, public.tl_2023_us_rails as railways
|
812 |
+
where st_contains(michigan.geom, railways.geom) and railways.fullname is not null
|
813 |
+
group by railways.fullname
|
814 |
+
)
|
815 |
+
select count(*) as num_railways
|
816 |
+
from michigan_railways;"
|
817 |
+
List 5 counties with most no of railways.,"02-county.txt,07-railways.txt","select county.name, count(railways.fullname) as num_railways
|
818 |
+
from tl_2023_us_rails as railways cross join tl_2023_us_county as county
|
819 |
+
where st_contains(county.geom, railways.geom)
|
820 |
+
group by railways.fullname, county.name
|
821 |
+
order by num_railways desc
|
822 |
+
limit 5;"
|
823 |
+
Which counties do At and Sf railway pass through?,"02-county.txt,07-railways.txt","select distinct county.name
|
824 |
+
from tl_2023_us_county as county cross join tl_2023_us_rails as railways
|
825 |
+
where st_contains(county.geom, railways.geom) and railways.fullname ilike '%at and sf%'"
|
826 |
+
Give me list of counties and number of railways in state of Florida.,"01-state.txt,02-county.txt,07-railways.txt","with florida as (
|
827 |
+
select geoid, geom
|
828 |
+
from tl_2023_us_state
|
829 |
+
where name ilike '%florida%'
|
830 |
+
limit 1
|
831 |
+
),
|
832 |
+
florida_railways as (
|
833 |
+
select county.name as county_name, railways.fullname as railway
|
834 |
+
from tl_2023_us_county as county cross join tl_2023_us_rails as railways, florida
|
835 |
+
where st_contains(florida.geom, county.geom) and st_contains(county.geom, railways.geom)
|
836 |
+
group by railways.fullname, county.name
|
837 |
+
)
|
838 |
+
select county_name, count(*)
|
839 |
+
from florida_railways
|
840 |
+
group by county_name;"
|
841 |
+
Which is the shortest railway in California?,"01-state.txt,07-railways.txt","with california as (
|
842 |
+
select geom
|
843 |
+
from tl_2023_us_state
|
844 |
+
where name ilike '%california%'
|
845 |
+
limit 1
|
846 |
+
)
|
847 |
+
select railways.fullname, sum(st_length(railways.geom::geography))/1000 as length_km
|
848 |
+
from california, tl_2023_us_rails as railways
|
849 |
+
where railways.fullname is not null and st_contains(california.geom, railways.geom)
|
850 |
+
group by railways.fullname
|
851 |
+
order by length_km asc
|
852 |
+
limit 1;"
|
853 |
+
Which county has the highest no of railways?,"02-county.txt,07-railways.txt","with county_railways as (
|
854 |
+
select county.name as county_name, rails.fullname as railway_name
|
855 |
+
from tl_2023_us_county as county cross join tl_2023_us_rails as rails
|
856 |
+
where st_contains(county.geom, rails.geom) and rails.fullname is not null
|
857 |
+
),
|
858 |
+
railway_counts as (
|
859 |
+
select county_name, count(railway_name) as railway_count
|
860 |
+
from county_railways
|
861 |
+
group by county_name
|
862 |
+
)
|
863 |
+
select county_name
|
864 |
+
from railway_counts
|
865 |
+
order by railway_count desc
|
866 |
+
limit 1;"
|
867 |
+
Which metropolitan city has the highest no of railways?,"04-metropolitan.txt,07-railways.txt","with metro_railways as (
|
868 |
+
select metro.name as metro_name, rails.fullname as railway_name
|
869 |
+
from public.tl_2023_us_cbsa as metro cross join tl_2023_us_rails as rails
|
870 |
+
where st_contains(metro.geom, rails.geom) and rails.fullname is not null and metro.lsad = 'M1'
|
871 |
+
),
|
872 |
+
railway_counts as (
|
873 |
+
select metro_name, count(railway_name) as railway_count
|
874 |
+
from metro_railways
|
875 |
+
group by metro_name
|
876 |
+
)
|
877 |
+
select metro_name
|
878 |
+
from railway_counts
|
879 |
+
order by railway_count desc
|
880 |
+
limit 1;"
|
881 |
+
What is the average no of railways in a metropolitan area in US?,"04-metropolitan.txt,07-railways.txt","with metro_railways as (
|
882 |
+
select metro.name as metro_name, rails.fullname as railway_name
|
883 |
+
from public.tl_2023_us_cbsa as metro cross join tl_2023_us_rails as rails
|
884 |
+
where st_contains(metro.geom, rails.geom) and rails.fullname is not null and metro.lsad = 'M1'
|
885 |
+
),
|
886 |
+
railway_counts as (
|
887 |
+
select metro_name, count(railway_name) as railway_count
|
888 |
+
from metro_railways
|
889 |
+
group by metro_name
|
890 |
+
)
|
891 |
+
select avg(railway_count) as average_railway_count
|
892 |
+
from railway_counts;"
|
893 |
+
What is the average no of railways in a micropolitan area in US?,"04-metropolitan.txt,07-railways.txt","with micro_railways as (
|
894 |
+
select micro.name as micro_name, rails.fullname as railway_name
|
895 |
+
from public.tl_2023_us_cbsa as micro cross join tl_2023_us_rails as rails
|
896 |
+
where st_contains(micro.geom, rails.geom) and rails.fullname is not null and micro.lsad = 'M2'
|
897 |
+
),
|
898 |
+
railway_counts as (
|
899 |
+
select micro_name, count(railway_name) as railway_count
|
900 |
+
from micro_railways
|
901 |
+
group by micro_name
|
902 |
+
)
|
903 |
+
select avg(railway_count) as average_railway_count
|
904 |
+
from railway_counts;"
|
905 |
+
Which states do not have any railways?,"01-state.txt,07-railways.txt","with state_with_railways as (
|
906 |
+
select distinct state.name
|
907 |
+
from tl_2023_us_state as state cross join tl_2023_us_rails as railways
|
908 |
+
where st_contains(state.geom, railways.geom)
|
909 |
+
group by state.name
|
910 |
+
)
|
911 |
+
select distinct state.name as states
|
912 |
+
from state_with_railways, public.tl_2023_us_state as state
|
913 |
+
where state.name not in (select name from state_with_railways);"
|
914 |
+
How many counties in US do not have any railways?,"02-county.txt,07-railways.txt","with county_with_railways as (
|
915 |
+
select distinct county.name
|
916 |
+
from tl_2023_us_county as county cross join tl_2023_us_rails as railways
|
917 |
+
where st_contains(county.geom, railways.geom)
|
918 |
+
group by county.name
|
919 |
+
)
|
920 |
+
select count(distinct county.name) as n_counties
|
921 |
+
from county_with_railways, public.tl_2023_us_county as county
|
922 |
+
where county.name not in (select name from county_with_railways);
|
923 |
+
"
|
924 |
+
What is the length of Missouri Pacific railway?,07-railways.txt,"select fullname, sum(st_length(geom::geography))/1000 as length_km
|
925 |
+
from tl_2023_us_rails
|
926 |
+
where fullname ilike '%missouri pacific%' and fullname is not null
|
927 |
+
group by fullname
|
928 |
+
limit 1;"
|
929 |
+
Provide me a list of 5 longest railways in US.,07-railways.txt,"select fullname, sum(st_length(geom::geography))/1000 as length_km
|
930 |
+
from tl_2023_us_rails
|
931 |
+
where fullname is not null
|
932 |
+
group by fullname
|
933 |
+
order by length_km desc
|
934 |
+
limit 5;"
|
geosql_dataset/load_tables.sh
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Set some variables
|
2 |
+
SHP_FILES_DIRECTORY = "" # absolute path of downloaded .zip files along with dataset.
|
3 |
+
UNZIP_DEST_DIRECTORY = "" # destination folder to unzip into .shp files
|
4 |
+
HOST_NAME = "" # postgres hostname
|
5 |
+
DB_NAME = "" # postgres database
|
6 |
+
PG_USER = "" # postgres user
|
7 |
+
|
8 |
+
# Unzip all the shapefiles
|
9 |
+
unzip $(SHP_FILES_DIRECTORY)/tl_2023_us_state -d $(UNZIP_DEST_DIRECTORY)/state
|
10 |
+
unzip $(SHP_FILES_DIRECTORY)/tl_2023_us_county -d $(UNZIP_DEST_DIRECTORY)/county
|
11 |
+
unzip $(SHP_FILES_DIRECTORY)/tl_2023_us_coastline -d $(UNZIP_DEST_DIRECTORY)/coastline
|
12 |
+
unzip $(SHP_FILES_DIRECTORY)/tl_2023_us_cbsa -d $(UNZIP_DEST_DIRECTORY)/cbsa
|
13 |
+
unzip $(SHP_FILES_DIRECTORY)/tl_2023_us_mil -d $(UNZIP_DEST_DIRECTORY)/mil
|
14 |
+
unzip $(SHP_FILES_DIRECTORY)/tl_2023_us_primaryroads -d $(UNZIP_DEST_DIRECTORY)/roads
|
15 |
+
unzip $(SHP_FILES_DIRECTORY)/tl_2023_us_rails -d $(UNZIP_DEST_DIRECTORY)/rails
|
16 |
+
|
17 |
+
# Load all these shapefiles into your postgres database with postgis extension enabled.
|
18 |
+
shp2pgsql -D -I -s 4269 $(UNZIP_DEST_DIRECTORY)/state/tl_2023_us_state.shp public.tl_2023_us_state | psql -d $DB_NAME -h $HOST_NAME -U $PG_USER
|
19 |
+
shp2pgsql -D -I -s 4269 $(UNZIP_DEST_DIRECTORY)/county/tl_2023_us_county.shp public.tl_2023_us_county | psql -d $DB_NAME -h $HOST_NAME -U $PG_USER
|
20 |
+
shp2pgsql -D -I -s 4269 $(UNZIP_DEST_DIRECTORY)/coastline/tl_2023_us_coastline.shp public.tl_2023_us_coastline | psql -d $DB_NAME -h $HOST_NAME -U $PG_USER
|
21 |
+
shp2pgsql -D -I -s 4269 $(UNZIP_DEST_DIRECTORY)/cbsa/tl_2023_us_cbsa.shp public.tl_2023_us_cbsa | psql -d $DB_NAME -h $HOST_NAME -U $PG_USER
|
22 |
+
shp2pgsql -D -I -s 4269 $(UNZIP_DEST_DIRECTORY)/mil/tl_2023_us_mil.shp public.tl_2023_us_mil | psql -d $DB_NAME -h $HOST_NAME -U $PG_USER
|
23 |
+
shp2pgsql -D -I -s 4269 $(UNZIP_DEST_DIRECTORY)/roads/tl_2023_us_primaryroads.shp public.tl_2023_us_primaryroads | psql -d $DB_NAME -h $HOST_NAME -U $PG_USER
|
24 |
+
shp2pgsql -D -I -s 4269 $(UNZIP_DEST_DIRECTORY)/rails/tl_2023_us_rails.shp public.tl_2023_us_rails | psql -d $DB_NAME -h $HOST_NAME -U $PG_USER
|
25 |
+
|
geosql_dataset/readme.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
This is a dataset made for the purpose of evaluating Text-to-SQL systems for geography-based applications.
|
2 |
+
Currently, we have only released 109 examples of natural_language, sql_query pairs.
|
3 |
+
|
4 |
+
Steps:
|
5 |
+
1. First, unzip all the .shp files and load them into your postgres database instance.
|
6 |
+
2. Load the text,sql pair from the .csv file into your desired program.
|
7 |
+
3. Generate SQL for the questions using your own LLM and compare the results any way you like.
|
8 |
+
|
9 |
+
###REQUIREMENTS.
|
10 |
+
1. You need postgres SQL installed with postgis extension enabled.
|
11 |
+
2. You need to have tiger geocoder enabled only for Florida state.
|
12 |
+
i.e., the geocoding done in this dataset is only on addresses from the Florida state.
|
13 |
+
For more information on installing tiger geocoder, see the book Postgis in Action by R. Obe, L. Hsu
|
14 |
+
Chapter 10: PostGIS TIGER geocoder
|
15 |
+
|
16 |
+
Copyright
|
17 |
+
reAlpha Tech Corp, 2024
|
18 |
+
|
19 |
+
Made by:
|
20 |
+
ML Team, Naamche
|
geosql_dataset/tiger_files/tl_2023_us_cbsa.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2f973d808101e07e618ea402cf61b34dc5d731ca6b2f4ede764a9fdeb0581ac1
|
3 |
+
size 34716117
|
geosql_dataset/tiger_files/tl_2023_us_coastline.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ed0c22593b4b5a19f17256916824cb4d665a45a1c0811c28c25caf12811f9ba9
|
3 |
+
size 16420208
|
geosql_dataset/tiger_files/tl_2023_us_county.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:692e12c30c83adcaabdbac0d3954fafa55e1c89a24b36d95e72e02dff938652e
|
3 |
+
size 83451409
|
geosql_dataset/tiger_files/tl_2023_us_mil.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:23fdfe692015ce1014c36e38ead6cd10e55fa52495000644f8bd822ae2d7c96f
|
3 |
+
size 2979085
|
geosql_dataset/tiger_files/tl_2023_us_primaryroads.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:97aad145a0c7b6285fb07e5119d3949f31d94e76803801a4c46eb8966e381a20
|
3 |
+
size 38247392
|
geosql_dataset/tiger_files/tl_2023_us_rails.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:43cc393be3dc4afb07b021ed7a029e578e173bf43af313681855732d5224ab28
|
3 |
+
size 33405492
|
geosql_dataset/tiger_files/tl_2023_us_state.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8ded0ef036e205e246ae4b03a66873f7e1eed50285b993702ce5aca674283a2e
|
3 |
+
size 9947818
|