1

I have a shapefile which I am converting into a geopandas dataframe. The CRS of this shapefile is epsg:4326 and I want to convert this to epsg:3857.

import geopandas as gp

file_path = 'zip_poly.shp'
sf = gp.read_file(file_path)
sf = sf[['ZIP_CODE','PO_NAME','STATE','geometry']]
sf = sf.to_crs(epsg=3857)

You can find the shapefile here.

The shapefile has around 33K zipcodes and it's taking too long to convert. Is there a better way to convert quickly?

  • 1
    No, because GeoPandas use Shapely for the geometries and Pyproj for the projections and you need to convert the 30745 geometries... – gene May 10 at 15:46
  • 1
    Indeed. To repeat what I said on SO: I think the code you show is the best option you have for now (how long is too long?). It might improve with the latest version of pyproj (>2.1), and there is work underway in GeoPandas to improve the performance, but that is not yet released. – joris May 10 at 16:06
  • @gene or joris Please post your comment as an answer so this thread can be marked as answered – underdark May 11 at 16:55
  • 1
    "Too long" and "quickly" are indefinite descriptors. Timing and requirements should be specified in milliseconds or seconds to thousandth resolution. An indication of the size of the data source and the number of vertices per feature should also be provided, lest the question be closed as unclear (folks shouldn't have to commit to downloading data from some 3rd party to understand the problem). – Vince May 11 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.