MapWindow 4 - ActiveX Control Programming : MapWindow Discussion Forum
I have a road.shp file with it's road.dbf table. I wish to find a road by it's name ( slect * from road where name="I40" ) and then zoom to the shape in the map view. I think I can do that by zoomtoshape() but I can't retrieve the object ID / Feature Id from t
identifying features by using attributes
Posted by:
nishith ()
Date: March 22, 2008 11:58PM
I have a road.shp file with it's road.dbf table.
I wish to find a road by it's name ( slect * from road where name="I40" )
and then zoom to the shape in the map view.
I think I can do that by zoomtoshape() but I can't retrieve the object ID / Feature Id from the select query above. There is no such column in the .dbf file !
But there has to be a entry like that - as arcgis must be correlating a feature with it's attributes some way , say by a primary key like feature Id (FID), isn't it so ?
Then why can't I see the entry for the object Id in the .dbf table ?
any solutions ?!?!?!
nishith
I wish to find a road by it's name ( slect * from road where name="I40" )
and then zoom to the shape in the map view.
I think I can do that by zoomtoshape() but I can't retrieve the object ID / Feature Id from the select query above. There is no such column in the .dbf file !
But there has to be a entry like that - as arcgis must be correlating a feature with it's attributes some way , say by a primary key like feature Id (FID), isn't it so ?
Then why can't I see the entry for the object Id in the .dbf table ?
any solutions ?!?!?!
nishith
Re: identifying features by using attributes
Posted by:
danames ()
Date: March 23, 2008 02:21AM
Nishith,
I think the steps would be something like this:
1) write a manual query for your record. To do this, you just need to cycle your records by looping through all shapes and viewing the attribute contents by using shapefile.get_cellvalue (.net) or shapefile.cellvalue (vb6). Once you find the record of interest then exit the loop.
2) Now you know the shapeID because that is the record you were on when you exited the loop.
Hope this helps,
Dan
I think the steps would be something like this:
1) write a manual query for your record. To do this, you just need to cycle your records by looping through all shapes and viewing the attribute contents by using shapefile.get_cellvalue (.net) or shapefile.cellvalue (vb6). Once you find the record of interest then exit the loop.
2) Now you know the shapeID because that is the record you were on when you exited the loop.
Hope this helps,
Dan
Re: identifying features by using attributes
Posted by:
jacksonmacd ()
Date: March 25, 2008 09:05AM
Nishith - one of the tools in the Attribute Table Editor is to create a new field in the DBF that contains a featureID. By default, the field is named MWShapeID. I think it will do what you want...
Re: identifying features by using attributes
Posted by:
nishith ()
Date: March 26, 2008 06:16AM
thanks for that info.
I found a easier way out.
I opened the shape file and then I found out the values of numfields and numshapes.
Then I looped through each field and each row to findout if the value I am looking for is in the cellvalue.
I used two nested for loops and the cellvalue function for that.
Whenever there is a match , I exit the loops and the loop counter which is keeping track of the rows give me the shape index of the object that I was looking for.
So I zoom to that shape on the shape index.
That's it.
If any newbie like me want the code snippet (vb.net) then let me know.
thanks
nishith
I found a easier way out.
I opened the shape file and then I found out the values of numfields and numshapes.
Then I looped through each field and each row to findout if the value I am looking for is in the cellvalue.
I used two nested for loops and the cellvalue function for that.
Whenever there is a match , I exit the loops and the loop counter which is keeping track of the rows give me the shape index of the object that I was looking for.
So I zoom to that shape on the shape index.
That's it.
If any newbie like me want the code snippet (vb.net) then let me know.
thanks
nishith
Re: identifying features by using attributes
Posted by:
JB ()
Date: August 05, 2008 02:58AM
Nisith,
I'm a newbie and would really like to see the code for this loop!
Thanks.
I'm a newbie and would really like to see the code for this loop!
Thanks.
Re: identifying features by using attributes
Posted by:
dwiswall ()
Date: September 18, 2008 08:17AM
I would like to see the code.
Thanks
Thanks
Re: identifying features by using attributes
Posted by:
Shade1974 ()
Date: October 10, 2008 03:51PM
Code cycling through the shapefile and looking at dbf values is illustrated here:
[www.mapwindow.org]
Shade1974
[www.mapwindow.org]
Shade1974
Re: identifying features by using attributes
Posted by:
eng.mokhtar ()
Date: October 21, 2008 06:00AM
hi Nisith,
Ilike to see the code snippet (vb.net)
Thanks.
Edited 1 time(s). Last edit at 10/21/2008 06:01AM by eng.mokhtar.
Ilike to see the code snippet (vb.net)
Thanks.
Edited 1 time(s). Last edit at 10/21/2008 06:01AM by eng.mokhtar.
Re: identifying features by using attributes
Posted by:
GISShamanth ()
Date: April 02, 2012 02:45AM
Nisith,
I'm a newbie and would really like to see the code for this loop!
Thanks.
I'm a newbie and would really like to see the code for this loop!
Thanks.
Re: identifying features by using attributes
Posted by:
GISShamanth ()
Date: April 02, 2012 02:47AM
Dear Ted, that link is not working(?)
The following page was not found: /wiki/index.php/MapWinGIS:SampleCode-VB_Net:ColorShapes
Our web site has undergone significant reorganization recently. Please use the menu bar above to locate the file or web page you were seeking.
If you arrived at this page through a dead link on the MapWindow web site, please contact us ASAP and let us know the page you linked from so that we can fix it. If you arrived at this page through a dead link on another web site, please notify the web master of that site so that they can update their links.
The following page was not found: /wiki/index.php/MapWinGIS:SampleCode-VB_Net:ColorShapes
Our web site has undergone significant reorganization recently. Please use the menu bar above to locate the file or web page you were seeking.
If you arrived at this page through a dead link on the MapWindow web site, please contact us ASAP and let us know the page you linked from so that we can fix it. If you arrived at this page through a dead link on another web site, please notify the web master of that site so that they can update their links.
Sorry, only registered users may post in this forum.


