Skip to content

Unable to retrieve data for some states using arc_read(): 'subscript out of bounds' error #242

@soheepark7

Description

@soheepark7

Hi, first of all thank you for creating this r package. I am sharing issues below.

*Describe the bug
When trying to read data for certain states (like Alabama, Alaska, and others) from the ArcGIS service using arc_read(), I encounter the error Error in x[[1]] : subscript out of bounds. However, data for Michigan (state code 26) and Minnesota (state code 27) is retrieved successfully without errors.

*To Reproduce

michigan_26_geo <- arc_read(
"https://tigerweb.geo.census.gov/arcgis/rest/services/Generalized_ACS2023/Tracts_Blocks/MapServer/4",
where = "STATE = '26'" # Michigan (works fine)
)

alabama_1_geo <- arc_read(
"https://tigerweb.geo.census.gov/arcgis/rest/services/Generalized_ACS2023/Tracts_Blocks/MapServer/4",
where = "STATE = '1'" # Alabama (gives error)
)

alaska_2_geo <- arc_read(
"https://tigerweb.geo.census.gov/arcgis/rest/services/Generalized_ACS2023/Tracts_Blocks/MapServer/4",
where = "STATE = '2'" # Alaska (gives error)
)

minnesota_27_geo <- arc_read(
"https://tigerweb.geo.census.gov/arcgis/rest/services/Generalized_ACS2023/Tracts_Blocks/MapServer/4",
where = "STATE = '27'" # Minnesota (works fine)
)

*Expected behavior
I expected the function to retrieve data for all states without errors.

Additional context

The error Error in x[[1]] : subscript out of bounds occurs for certain states (Alabama, Alaska, and others), while data retrieval works correctly for Michigan and Minnesota.
The issue might be related to missing or incomplete data for certain states in the ArcGIS service.
I’m using the arcgislayers package in R for this operation.
Final Command
I ultimately want to fetch data for all states at once using the following command:

geo_all_acs2023 <- arc_read(
"https://tigerweb.geo.census.gov/arcgis/rest/services/Generalized_ACS2023/Tracts_Blocks/MapServer/4",
where = "STATE IN ('1', '2', '4', '5', '6', '8', '9', '10', '12', '13',
'15', '16', '17', '18', '19', '20', '21', '22', '23',
'24', '25', '26', '27', '28', '29', '30', '31', '32',
'33', '34', '35', '36', '37', '38', '39', '40', '41',
'42', '44', '45', '46', '47', '48', '49', '50', '51',
'53', '54', '55', '56')"
)

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions