0

I'm working with a geodataframe called college3

college3 = gpd.GeoDataFrame(pd.read_table('data.txt'),crs = {'init': 'epsg:4269'})

The shape column was originally written in the format:

country type    color   relver  shape   _imported   _dataset    uniq_id pop
67  10  1781    1788    166452  Lesley University   Art Institute of  Boston    700 Beacon Street   Boston  MA  2215    ... 25025   USA 4-Year, Private 10  1.13.3  0106000020157C01000100000001030000000100000005...   2013-09-24 09:14:10 2013-01-01 00:00:00 d7a43fd5b64ce70481de5e6f057e99f4    480.694851
68  10  1995    2002    165167  Cambridge College   Main Campus 1000 Massachusetts Avenue, Suite 31 Cambridge   MA  2138    ... 25017   USA 4-Year, Private 0   1.13.3  0106000020157C01000200000001030000000100000005...   2013-09-24 09:14:10 2013-01-01 00:00:00 b57a1f68ea10a72ec9f53fece669f2cb    8942.000000
69  10  1025    1026    166513  University of Massachusetts Lowell  UML South   1 Solomont Way  Lowell  MA  1854    ... 25017   USA NaN 5   1.13.3  0106000020157C01000100000001030000000100000021...   2013-09-24 09:14:10 2013-01-01 00:00:00 a961b9066a579a5d6d56a0e91f3ce1be    10456.345189
70  10  509 509 164924  Boston College  Newton Campus   885 Centre Street   Newton Centre   MA  2459    ... 25017   USA NaN 10  1.13.3  0106000020157C01000100000001030000000100000030...   2013-09-24 09:14:10 2013-01-01 00:00:00 d8f31b0bde7553d795bd68ba697c6b5c    5589.823847
72  10  2160    2167    167376  Northern Essex Community College    Main    100 Elliot Street   Haverhill   MA  1843    ... 25009   USA 2-Year, Public  0   1.13.3  0106000020157C0100010000000103000000010000007F...   2013-09-24 09:14:10 2013-01-01 00:00:00 dc686ca64b68ad0e18137f576caee96a    19264.000000

I converted the hex shape by doing the following:

college3['geometry'] = np.nan
for i in range(0, len(college3)):
    college3['geometry'].iloc[i] = shapely.wkb.loads(hex=True,data=college3['shape'].iloc[I])

which yielded a new college3['geometry']:

0    (POLYGON ((1045282.478239882 1257128.653710355...
1    (POLYGON ((1114508.897557752 1243969.445296504...
2    (POLYGON ((1023386.780084164 1265306.580706236...
3    (POLYGON ((1043605.376445292 1281471.656769202...
4    (POLYGON ((1064893.875765753 1254220.62727893,...

however, I would like to project college3['geometry'] to epsg=4269. When I try

college3 = college3.to_crs(epsg=4269)
college3['geometry'].head()

I get the same results:

0    (POLYGON ((1045282.478239882 1257128.653710355...
1    (POLYGON ((1114508.897557752 1243969.445296504...
2    (POLYGON ((1023386.780084164 1265306.580706236...
3    (POLYGON ((1043605.376445292 1281471.656769202...
4    (POLYGON ((1064893.875765753 1254220.62727893,...

How do I change my college3['geometry'] to lat long epsg=4269 ? I'd greatly appreciate any help

M3105
  • 519
  • 2
  • 7
  • 20
  • You initially put the `crs` of the GeoDataFrame to `{'init': 'epsg:4269'}` (first line of code), that's the reason that then the `to_crs(epsg=4269)` call did not change anything. – joris Feb 16 '18 at 07:39
  • if I take off `{'init': 'epsg:4269'}` from the geodataframe, then when I try to do `college3 = college3.to_crs(epsg=4269)` I get the following error: `ValueError: Cannot transform naive geometries. Please set a crs on the object first.` – M3105 Feb 16 '18 at 13:09
  • could this be happening since my data came from a txt file rather than a shapefile? – M3105 Feb 16 '18 at 14:59
  • Yes, that error is to be expected. You need to know in which CRS your original data is, and set it first before you can convert it to another CRS (as you did with `crs = {'init': 'epsg:4269'}`, but then with the correct epsg number) – joris Feb 16 '18 at 17:31
  • I see, how can I figure out which CRS my original data is in? – M3105 Feb 16 '18 at 19:26
  • when I try typing `college3.crs` it does not yield what the original crs is – M3105 Feb 16 '18 at 19:34
  • @M3105 aside from guessing and checking with EPSG codes that are valid for your region, you have to dig into the provenance of the data. Who generated it? How? etc – Paul H Feb 16 '18 at 21:15
  • unfortunatelyI have no documentation in regards to the data. How would I go about guessing and checking which EPSG codes are valid? – M3105 Feb 16 '18 at 21:50
  • the first geometry is `1045282.478239882 1257128.653710355` which I have no idea what type of lat long that is? – M3105 Feb 16 '18 at 22:01

0 Answers0