Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to get GlobalID if OID is not found in retrieved feature (arcgis) #2425

Merged
merged 7 commits into from
Oct 11, 2024

Conversation

AlvaroVega
Copy link
Member

@AlvaroVega AlvaroVega commented Oct 7, 2024

Before this get_objectId was returning -1 even if no ObjectID is found in entity

Related #2424 (comment)

@AlvaroVega AlvaroVega marked this pull request as ready for review October 8, 2024 07:37
@AlvaroVega
Copy link
Member Author

AlvaroVega commented Oct 8, 2024

About GlobalID and ObjectID in ArcGIS: (by chatGPT)

The GlobalID is not a direct substitute for the ObjectID in ArcGIS, although both are unique identifiers. There are key differences between these two fields in terms of purpose and behavior:
Key Differences:

Purpose:
    ObjectID: This is an automatically generated field used to uniquely identify features in a feature class or table. Its primary function is to help ArcGIS manage features internally, enabling operations like editing, selection, and geoprocessing. It is crucial for many tasks in ArcGIS.
    GlobalID: This is a globally unique identifier (UUID) that is also automatically generated, but its purpose is to ensure uniqueness across different geodatabases or environments. GlobalIDs are mainly used for replica synchronization or relationships between tables when features are shared across multiple databases or systems. This field is especially useful in scenarios like replication or versioning, particularly in distributed environments.

Uniqueness:
    ObjectID: It is unique within a table or feature class but not globally. If you have multiple tables or databases, there may be duplicate ObjectIDs across them.
    GlobalID: It is globally unique. Regardless of the geodatabase or environment, each GlobalID is distinct.

Modification:
    ObjectID: It cannot be edited or manipulated by the user. It is automatically managed by ArcGIS and generated when a new feature is created.
    GlobalID: It is also automatically generated by ArcGIS and cannot be edited by the user, but its use is more specific and optional depending on the workflow.

Requirement for certain operations:
    ObjectID: It is required by ArcGIS for many standard operations like selection, editing, and various geoprocessing tools. Some operations will not work if the layer does not have an ObjectID.
    GlobalID: It is not required for most common operations in ArcGIS. It is mainly used in advanced workflows like replication, versioning, or maintaining relationships between tables (one-to-many or many-to-many relationships).

Can GlobalID substitute for ObjectID?

In general, no. The ObjectID is fundamental for ArcGIS’s internal functioning and is required for basic tasks like editing, selection, and geoprocessing. The GlobalID serves a different purpose, primarily related to synchronization and managing relationships between distributed features.

While both are unique identifiers, many ArcGIS tools specifically need an ObjectID to function. If your layer or table lacks an ObjectID, you cannot simply use a GlobalID as a replacement for functions that require the ObjectID.
When to use GlobalID?

Use GlobalID in cases such as:

When working with replicas and ensuring that identifiers remain unique, even when moving data between different geodatabases.
To maintain integrity in relationships between features or tables in distributed systems.
In versioning or disconnected editing workflows where you need to uniquely identify features across multiple databases.

In summary, the GlobalID has a specialized use case and cannot replace the ObjectID for many basic ArcGIS operations.

@AlvaroVega
Copy link
Member Author

AlvaroVega commented Oct 8, 2024

About if is possible than a featrue has no ObjectId in ArcGIS: (by ChatGPT)

In ArcGIS, it is not normal for a feature to lack an ObjectID, as this field is essential for many core functionalities. The ObjectID is an automatically generated unique identifier for each feature in a feature class or table, and it is required for tasks such as selection, editing, and geoprocessing.

However, there are certain scenarios where a feature might not have an ObjectID:

Non-spatial tables: Some tables without geometries, like CSV or Excel files, might not have an ObjectID. These are typically used for managing attribute data rather than spatial features.

Joined layers: If a feature class is joined to a table that lacks an ObjectID, the resulting layer may not retain the ObjectID field, especially in one-to-many joins.

External data sources: Data from formats like GeoJSON, KML, or external web services (WFS, WMS) may not include an ObjectID, as it is not required by those standards.

Temporary layers: Features generated from analysis tools or temporary layers may lack an ObjectID until saved as a permanent feature class in a geodatabase.

Consequences of lacking an ObjectID:

You cannot perform operations like selection, editing, or certain types of analysis.
Some geoprocessing tools will not work without an ObjectID.

If your feature does not have an ObjectID and you need one, you can usually create it by exporting the data to a new feature class or saving it in a geodatabase, which will automatically generate the ObjectID field.

@AlvaroVega AlvaroVega changed the title check if really objectId is found check if really objectId is found (arcgis) Oct 8, 2024
@AlvaroVega AlvaroVega changed the title check if really objectId is found (arcgis) check if really objectId is found in feature in feature (arcgis) Oct 8, 2024
@AlvaroVega AlvaroVega changed the title check if really objectId is found in feature in feature (arcgis) check if really objectId is found in feature (arcgis) Oct 11, 2024
@AlvaroVega AlvaroVega changed the title check if really objectId is found in feature (arcgis) Try to get GlobalID if OID is not found in retrieved feature (arcgis) Oct 11, 2024
@AlvaroVega AlvaroVega requested a review from fgalan October 11, 2024 10:42
Copy link
Member

@fgalan fgalan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fgalan fgalan merged commit 5f534da into master Oct 11, 2024
7 checks passed
@fgalan fgalan deleted the fix/check_object_id_not_found_by_get_object branch October 11, 2024 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants