I am trying to convert values from geographical coordinates to UTM and writing out a new shapefile.
To access records, I am using iterRecords() from the shapefile.Reader object and noticed record number is -1 instead of actual index.
When accessed using records(), I see correct record number for the record.
# Reader for source file
r = shapefile.Reader('NYC_MUSEUMS_GEO/NYC_MUSEUMS_GEO')
# Writer for target/modified file
w = shapefile.Writer(target='NYC_MUSEUMS_GEO/NYC_MUSEUMS_UTM', shapeType=r.shapeType)
w.fields = list(r.fields)
# Populate records
# for record in r.records():
for record in r.iterRecords():
print(record)
# Logic to be added for modification
# Close file objects
r.close()
w.close()
Record #0: ['Alexander Hamilton U.S. Custom House', '(212) 514-3700', 'http://www.oldnycustomhouse.gov/', '1 Bowling Grn', '', 'New York', 10004.0]
Record #1: ['Alice Austen House Museum', '(718) 816-4506', 'http://www.aliceausten.org/', '2 Hylan Blvd', '', 'Staten Island', 10305.0]
Record #2: ['American Academy of Arts and Letters', '(212) 368-5900', 'http://www.artsandletters.org/', '633 W. 155th St.', '', 'New York', 10032.0]
Record #3: ['American Folk Art Museum', '(212) 265-1040', 'http://www.folkartmuseum.org/', '45 West 53rd Street', '', 'New York', 10019.0]
And with iterRecords():
Record #-1: ['Alexander Hamilton U.S. Custom House', '(212) 514-3700', 'http://www.oldnycustomhouse.gov/', '1 Bowling Grn', '', 'New York', 10004.0]
Record #-1: ['Alice Austen House Museum', '(718) 816-4506', 'http://www.aliceausten.org/', '2 Hylan Blvd', '', 'Staten Island', 10305.0]
Record #-1: ['American Academy of Arts and Letters', '(212) 368-5900', 'http://www.artsandletters.org/', '633 W. 155th St.', '', 'New York', 10032.0]
Record #-1: ['American Folk Art Museum', '(212) 265-1040', 'http://www.folkartmuseum.org/', '45 West 53rd Street', '', 'New York', 10019.0]
Is this how it is supposed to be or there need to be change done?
You were correct, that was a bug, so thanks for pointing it out! Fixes and tests have now been added to ensure that all methods have the correct oid. Much appreciated!
I am trying to convert values from geographical coordinates to UTM and writing out a new shapefile. To access records, I am using iterRecords() from the shapefile.Reader object and noticed record number is -1 instead of actual index. When accessed using records(), I see correct record number for the record.
Data used in the example can be found here
With records():
And with iterRecords():
Is this how it is supposed to be or there need to be change done?
Thank you