Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_shapefile doesn't pick up crs (also, not sure how to get crs without pyarrow) #871

Closed
deanm0000 opened this issue Nov 22, 2024 · 2 comments · Fixed by #919
Closed

Comments

@deanm0000
Copy link

I tried with this file https://www2.census.gov/geo/tiger/GENZ2018/shp/cb_2018_us_state_500k.zip

grctab = read_shapefile(shpfile, dbffile)
patab = pa.table(grctab)
pa.table(gg)['geometry'].type.crs
## returns
''
gpdtab = gpd.read_file(shp_file_dir)
gpdtab.crs
## returns
<Geographic 2D CRS: EPSG:4269>
Name: NAD83
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: North America - onshore and offshore: Canada - Alberta; British Columbia; Manitoba; New Brunswick; Newfoundland and Labrador; Northwest Territories; Nova Scotia; Nunavut; Ontario; Prince Edward Island; Quebec; Saskatchewan; Yukon. Puerto Rico. United States (USA) - Alabama; Alaska; Arizona; Arkansas; California; Colorado; Connecticut; Delaware; Florida; Georgia; Hawaii; Idaho; Illinois; Indiana; Iowa; Kansas; Kentucky; Louisiana; Maine; Maryland; Massachusetts; Michigan; Minnesota; Mississippi; Missouri; Montana; Nebraska; Nevada; New Hampshire; New Jersey; New Mexico; New York; North Carolina; North Dakota; Ohio; Oklahoma; Oregon; Pennsylvania; Rhode Island; South Carolina; South Dakota; Tennessee; Texas; Utah; Vermont; Virginia; Washington; West Virginia; Wisconsin; Wyoming. US Virgin Islands. British Virgin Islands.
- bounds: (167.65, 14.92, -40.73, 86.45)
Datum: North American Datum 1983
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich

As an aside, I would just make a request that instead of taking the two files as input it would just take the directory or, for bonus points, a zip file containing a shapefile directory.

@kylebarron
Copy link
Member

The shapefile reader does not yet handle files other than .shp and .dbf. Help would be appreciated to ensure we handle the .cpg file (for the text encoding in the .dbf) and the .prj file.

One blocker here is that in the GeoArrow spec we currently require PROJJSON. That needs to be relaxed to allow any CRS information, because we have no way to convert the .prj file to PROJJSON. See https://github.com/geoarrow/geoarrow/pull/40/files

@kylebarron
Copy link
Member

You can use geoarrow.rust.core.get_crs to access the CRS of a file. See

def get_crs(
data: ArrowArrayExportable | ArrowStreamExportable | ArrowSchemaExportable,
/,
column: str | None = None,
) -> pyproj.CRS | None:

But it looks like we're missing that function from the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants