TransWikia.com

Does pyshp read .prj files properly?

Geographic Information Systems Asked on December 23, 2020

I want to read a shapefile using pyshp:

sf = shapefile.Reader(('/tmp/India_PCs_Boundary_4_2_19/India_PCs_Boundary.shp'))

but when I look at the result, the polygons look all squishy and distorted; they’re supposed to exactly cover India, but they don’t.

One theory for what might have happened is that I did not read the .prj file correctly, and the .prj file contained some sort of projection data that would un-distort the polygons.

When I read the pyshp documentation, it says:

You specify the base filename of the shapefile or the complete filename
of any of the shapefile component files….
OR any of the other 5+ formats which are potentially part of a shapefile. The
library does not care about file extensions.

But it does not mention .prj specifically.

Does pyshp, by default, read .prj files correctly? If not, is there a way to get it to do so?

One Answer

PyShp does not handle projections. You can use pyproj for that. What are you using to visualize the shapefile? If the data is in a geographic coordinate system, it won't appear in the cartesian format that you are expecting.

Answered by DJH on December 23, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP