Giter Site home page Giter Site logo

Comments (3)

nanaeaubry avatar nanaeaubry commented on June 12, 2024

@skykasko
How are you getting the JSON for the GeoAccessor? df1.spatial.json?

The compare method uses a panda's merge method so if you are seeing difference in the panda's to_json then that would explain the fact that difference are found when merging.

I would do some data manipulation on the data and make sure they are rounded to the same decimal place. It seems the issue might arise to how the data is stored in Online vs the other source.

@achapkowski do you have any input?

from arcgis-python-api.

skykasko avatar skykasko commented on June 12, 2024

How are you getting the JSON for the GeoAccessor? df1.spatial.json?

df1[df1.spatial.name][0].JSON. See the example above, where the expression df1[df1.spatial.name][0].JSON == df2[df2.spatial.name][0].JSON evaluated to True.

I would do some data manipulation on the data and make sure they are rounded to the same decimal place.

How would you recommend going about this? Calling df1.round(5) has no effect on the shape column, and calling df1[df1.spatial.name].round(5) raises the error AttributeError: 'GeoArray' object has no attribute 'round'.

I suppose I could apply a custom function to the shape column that iterates over all the coordinate values and rounds them one by one. For my example above, the following works:

def round_shape(shape):
    roundedPaths = []
    for path in shape["paths"]:
        roundedPaths.append([[round(coord, 5) for coord in point] for point in path])
    return {"paths": roundedPaths, "spatialReference": shape["spatialReference"]}

df1[df1.spatial.name] = df1[df1.spatial.name].apply(round_shape)
# Manipulating the geometry column appears to make the DataFrame no longer
# recognized as Spatially Enabled, so the geometry column needs to be reassigned.
df1.spatial.set_geometry("SHAPE")

But this could be tricky to get right for every possible geometry type, and at that point using GeoAccessor.compare() may be more complicated than writing a custom comparison function that uses GeoSeriesAccessor.equals() to check for geometry differences and Pandas' built-in DataFrame.compare() to check for other differences.

from arcgis-python-api.

nanaeaubry avatar nanaeaubry commented on June 12, 2024

@skykasko
Creating a custom round method is the way to go. Otherwise you can look into other libraries that have some methods such as almost_equals in the Shapely library or if you have arcpy you can use the generalize operation or boundary.

https://stackoverflow.com/questions/63402333/how-does-almost-equals-function-of-shapely-treat-the-starting-point-and-errors
https://pro.arcgis.com/en/pro-app/latest/tool-reference/editing/generalize.htm

You can also post on the Esri Community forum to see if other users have come across this or have suggestions.

from arcgis-python-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.