0

I'm trying to work with the London Borough borders file (https://data.london.gov.uk/dataset/statistical-gis-boundary-files-london) in geopandas/geoplot.

It comes in National Grid Easting/Northing coordinates (epsg="7405" I think) and I'm trying to convert to Lat Longs to be able to map, but the first row of any dataframe I convert keeps being changed to an "INF INF" polygon!

No idea why it's happening. I've tried doing different rows, only one row, changing the CRS....same issue.

all_border = geopandas.read_file("boroughs\London_Borough_Excluding_MHW.tab")


lsoa_border.to_crs(epsg=4327)

enter image description here

5
  • OSGB is EPSG:27700
    – Ian Turton
    Dec 15 '20 at 10:04
  • Welcome to gisexchange.com. You may check the answer of Trish to this question: stackoverflow.com/questions/55390492/…. He uses geopandas for reprojection too.
    – ilias m
    Dec 15 '20 at 11:26
  • @iliasm it does look like the same pyproj error - thank you!
    – Crimsoneer
    Dec 15 '20 at 11:32
  • In addition, in your screenshot, you have written epsg: 4327 but at the title is: 4326. I guess it is a mistake. Did you mean 4326?
    – ilias m
    Dec 15 '20 at 11:36
  • Ah yes, was trying a few different things. have corrected title
    – Crimsoneer
    Dec 15 '20 at 11:52
0

I think I've figured out what is going on...for some reason, the first time I run the re-project, it doesn't finish the first row. A workaround is doing it via Shapely, and re-inserting it into the new DF. Even then, weirdly it doesn't seem to work the first time...some sort of memory bug?

Anyway, running the below twice seems to work.

import pyproj
from shapely.ops import transform

def fix_df(old_df, new_df):
    OSGB = pyproj.CRS.from_epsg(27700 )
    lat_long = pyproj.CRS.from_epsg(4326)
    project = pyproj.Transformer.from_proj(OSGB, lat_long)
    g1 = old_df.iloc[0].geometry
    g2 = transform(project.transform, g1 )  # apply projection
    new_df.loc[0, "geometry"] = g2
    return new_df

EDIT: This looks likely connected to this pyproj bug: https://stackoverflow.com/questions/55390492/runtimeerror-bno-arguments-in-initialization-list

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.