0

I'm trying to process some data, with geopandas0.9.

Here is my code:

locations = select_polygons.groupby(class_col).apply(lambda x: \
            sample_locations_from_polygon(x, sample_on_boundary='road'
            in x[class_col].iloc[0].lower() or 'railway'
            in x[class_col].iloc[0].lower()))
    return locations

Here class_col="ITEM"

It gives me error saying: ValueError: 'ITEM' is both an index level and a column label, which is ambiguous.

Here is what the data looks like: https://gist.github.com/maifeeulasad/611f82f63ceb64bb00c117116897323e#file-dump-md

Couldn't paste it here, due to it's extensive size.

How can I resolve this? I'm fresh in GIS.

I've tried this:

class_col='_ITEM'
    locations = select_polygons.groupby(class_col).apply(lambda x: \
            sample_locations_from_polygon(x, sample_on_boundary='road'
            in x[class_col].iloc[0].lower() or 'railway'
            in x[class_col].iloc[0].lower()))
    return locations

Then it says: KeyError: '_ITEM'

I've also tried setting the index, manually

select_polygons.set_index('_ITEM')

But that raises another error, saying: "None of ['_ITEM'] are in the columns"

3
  • Is the sample_locations_from_polygon function something that you created yourself? If so, what does its body look like? If not, where is it imported from?
    – Felipe D.
    Jul 12 '21 at 16:59
  • Looks like this is the source of that function? github.com/adrianalbert/urban-environments/blob/master/…
    – toms
    Jul 12 '21 at 17:22
  • the source is from urban-atlas, I;ve updated the question... can you guys check again. Jul 13 '21 at 8:09

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.