View Full Version : Query Location
rad.77676
2005-08-29, 07:53 PM
I have 3000+- quarter sections that I need to query. Is there a simple way to save the location coordinates for all of these sections to external query files?
I know I could select each one and save to external file, just hoping someone has a better idea!
Thanks,
Rob
MHultgren
2005-08-29, 09:22 PM
Are you wanting to save the window limits of each one or just the centroid? If you have LDT, place a point at the intersections and you can export the coords (X.Y.and Z - if needed) to a file. and then build a template query to pull in the type of data you want, then use the ol' cut - n - paste (in your favorite ascii editor) to change the coordinates for each section, do a save-as with section number or something that makes sense. Here is the format of the qry file. Make sure that you have created your project info prior to generating the template, build your query and run it on the first section to make sure you have everything you need showing, then save that to an external file. Open that file and look for the areas in red below to see what you would need to change. I would probably round off the coordinates and give yourself a bit of a buffer ( add or subtract 10 to each X and Y coordinate to make sure your get the whole section.
(setq ade_cmddia_before_qry (getvar "cmddia"))
(setvar "cmddia" 0)
(mapcar 'ade_dwgdeactivate (ade_dslist))
(setq ade_tmpprefval (ade_prefgetval "ActivateDwgsOnAttach"))
(ade_prefsetval "ActivateDwgsOnAttach" T)
(setq dwg_id(ade_dsattach "path(s) of drawings to query"))
(ade_prefsetval "ActivateDwgsOnAttach" ade_tmpprefval)
(ade_qryclear)
(ade_qrysettype "draw")
(ade_qrydefine '("" "" "" "Location" ("window" "inside" (681885.371764 920871.924347 0.000000)(683411.390529 919379.271217 0.000000))""))
(ade_qrydefine '("AND" "" "" "Property" ("objtype" "=" "object types")""))
(ade_qrydefine '("AND" "" "" "Property" ("layer" "=" "layers")""))
(ade_qrysetaltprop nil)
(ade_qryexecute)
(setvar "cmddia" ade_cmddia_before_qry)Once you build your "Template query, you should only have to change the coords and do a save-as.
rad.77676
2005-08-29, 11:02 PM
Mark,
Thanks for the tip, that is basically what I'm trying to avoid.
I'm guessing I'm not the first person to deal with Local Agency GIS data.
I'm trying to break down 953MB of data into quarter section size drawings so our designers can open them.
With help from others here, I have the routine to query and block out each drawing, but I'm trying to find a better way to put together the query files that contain the location of each quarter section boundary.
I have created them in the past just by defining the query location and selecting a boundary.
I don't want to cut & paste 3000 query files, if there is a better way, just thought I would check and see if anyone has come across this already.
Thanks again,
Rob
MHultgren
2005-08-29, 11:17 PM
Rob,
You could always dump the section coords into an MDB and set up your queries from there using the quarter section number as the index field?
Are you trying to break out topo for each section? Take a look at WWW.DOTSOFT.COM (http://www.DOTSOFT.COM). Terry has a new tool that might be just what you are looking for. It is called GridWorks. Not sure if it is what you are looking for, but it might be of some assistance
rad.77676
2005-08-30, 04:28 PM
Rob,
You could always dump the section coords into an MDB and set up your queries from there using the quarter section number as the index field?
M,
Newbie here!
How would I go about doing this?
Thanks,
Rob
MHultgren
2005-08-30, 04:43 PM
Well, you would need to start by registering and catching up with the ATP085 course (under Education - ATP Courses) while you still can. This will give you the training to access and talk with MS Access for your MDB. Once you get through that, then you would be able to connect to that DB from the Map Pulldown. It is a bit much to try explain breifly on here though. Pull out the Help file and tutorials to walk you through the procedures.
<from the ACMAP Help File>
Using AutoCAD Map, you can link information from an external database to objects in your drawing, and then retrieve objects from source drawings using the linked information. For example, with a database of traffic flow information, you can link traffic records in the database to roads in the drawing, and then run a query to display only those roads with high volume traffic.
After you create the links, use the Data View to select, highlight, view, and edit records in the database table.
The first step in using external databases is to attach the data source to your project (http://ms-its:C:Program%20FilesLand%20Desktop%20R2Helpacmap.chm::/exdata_1_0_datasource_c.htm).
You can view the external table using AutoCAD Map's Data View (http://ms-its:C:Program%20FilesLand%20Desktop%20R2Helpacmap.chm::/exdata_2_0_dataview_c.htm). You can customize the look of the Data View (http://ms-its:C:Program%20FilesLand%20Desktop%20R2Helpacmap.chm::/exdata_3_0_customizedv_c.htm) and hide and freeze columns in the display.
If you want to link records from the table to objects in your drawing, create a link template (http://ms-its:C:Program%20FilesLand%20Desktop%20R2Helpacmap.chm::/exdata_4_0_managelt_c.htm) that specifies how to uniquely identify each record in the table.
Once you create a link template, you can link records from the table to objects in your drawing (http://ms-its:C:Program%20FilesLand%20Desktop%20R2Helpacmap.chm::/exdata_5_0_linkrecords_c.htm).
You can then use those links to view and select objects based on their linked data (http://ms-its:C:Program%20FilesLand%20Desktop%20R2Helpacmap.chm::/exdata_6_0_uselinks_c.htm).
You can also set options (http://ms-its:C:Program%20FilesLand%20Desktop%20R2Helpacmap.chm::/exdata_7_0_options_c.htm) that specify how you use external database tables with AutoCAD Map.
rad.77676
2005-08-30, 05:27 PM
Thanks Mark!
jim.dahl
2005-08-30, 06:11 PM
Sounds like the Database approach is a good one, but try link to the poly. I believe the mapbooks does this, which sounds like what you are trying to accomplish. To create the link you probably could generate on the unique quarter section number. I had this set up for our county in Map 2005 with 1440 half sections, but the Mapbooks in 2005 was not good enough in my opinion so heard 2006 was better.
jim
rad.77676
2005-08-30, 06:29 PM
Jim,
How do I go about creating links from polyline boundaries, I only see options to link text or blocks.
Rob
jim.dahl
2005-08-31, 01:24 PM
What works for one might not work for others, so there are a number of ways to approach the task. I attached a sample of a project for a Township quarter-quarter section. I have done this at least three different ways and will explain a basic way to create the links, but forgot how to do the query; maybe someone else can explain that but the map set knows the extent of the polygon when you set up the query on the unique ID.
1. Start with polygon.
2. Have centroid of unique ID.
3. Create object table with one field.
4. Drag and drop MDB (with the ID as one of the fields) into project space.
5. Generate links based on the text enclosed.
At this point you have the DWG with polys that have a link to the MDB so each record is spatially aware of where it is.
I am eager to learn how to create the map book in Map 2006 because have heard that you have much more flexibility in previewing and plotting each cell of the grid.
BTW, if you have access to ArcGIS, the DS Mapbook is a model that I was hoping that AutoDesk developers would follow, and if someone knows of a routine for that, I definitely would be interested!!!!
Good Luck and please let us know how it works.
I see a bug in the way I created centroids and needd to redo that to maintain text WITHIN poly.
Jim
rad.77676
2005-09-01, 07:14 PM
1. Start with polygon.
2. Have centroid of unique ID.
Jim
Jim,
The polyline boundaries I have are mostly closed polyline rectangles, how can I create a topology and create centroids for these if you cannot have intersecting polylines in a topology?
I keep getting an error when trying to create a topology, I'm assuming that it is because my quarter sections boundaries overlap/meet each other.
Any ideas on how to deal with this?
Thank you,
Rob
mohobrien
2005-09-01, 08:06 PM
You end up with those errors when you have things like dangles or intersecting lines. None of your polygons should be overlapping to cause intersections as each polygon should be a unique 1/4 section. You should first run the map cleanup tools on your polygons. First break all crossings, then delete all duplicates until all you have are the polylines (not closed) that make up the polygons. Then you can do a topology. Then from that topology you can create the closed polygons.
How have you identified your 1/4 sections in your drawing? Attached object data or enclosed text?
rad.77676
2005-09-01, 08:17 PM
You end up with those errors when you have things like dangles or intersecting lines. None of your polygons should be overlapping to cause intersections as each polygon should be a unique 1/4 section. You should first run the map cleanup tools on your polygons. First break all crossings, then delete all duplicates until all you have are the polylines (not closed) that make up the polygons. Then you can do a topology. Then from that topology you can create the closed polygons.
How have you identified your 1/4 sections in your drawing? Attached object data or enclosed text?
M,
If I run cleanup on my boundaries, it deletes overlapping linework and since each quarter section is virtually connected, I no longer have a closed boundary.
The quarter sections are defined by polylines that I queried from GIS data along with the legal description for each.
Rob
mohobrien
2005-09-01, 08:36 PM
If I run cleanup on my boundaries, it deletes overlapping linework and since each quarter section is virtually connected, I no longer have a closed boundary.
Yes, that's right. Thats how you create a topology. Once all adjoining boundaries are reduced to the single boundary line, the topology uses that pline as one of its 'polygon' sides. That same pline is used as a boundary of the adjoining polygon. That's how a topology relates the various polylines in a polygon topology. The tool 'Create closed polylines' is what you use to create closed polylines from that topology. How were your 1/4 sections identified in your drawing when you had just the original closed polylines?
rad.77676
2005-09-01, 08:58 PM
Yes, that's right. Thats how you create a topology. Once all adjoining boundaries are reduced to the single boundary line, the topology uses that pline as one of its 'polygon' sides. That same pline is used as a boundary of the adjoining polygon. That's how a topology relates the various polylines in a polygon topology. The tool 'Create closed polylines' is what you use to create closed polylines from that topology. How were your 1/4 sections identified in your drawing when you had just the original closed polylines?
Got it!
Next question,
When I specify a location in a query and save that location "coordinates" to an external query file, I can then call them from a lisp routine.
Now that I went through the trouble of linking access to map, can I somehow get those coordinates where I can call them from lisp?
Rob
mohobrien
2005-09-01, 09:10 PM
What kind of fields do you have in your access db?
rad.77676
2005-09-01, 09:29 PM
What kind of fields do you have in your access db?
I created two fields
boundaries - legal description - text link in drawing
coordinates - blank
Rob
mohobrien
2005-09-01, 09:37 PM
So your drawing of the 1/4 sections already has a unique identifying number inside each polygon? If so, there is no need for linking to a db if what you want to do is use those polygon boundaries as the basis for querying from a larger drawing. ie a new drawing for each 1/4 section. What you can use are plot sets.
rad.77676
2005-09-01, 09:40 PM
So your drawing of the 1/4 sections already has a unique identifying number inside each polygon? If so, there is no need for linking to a db if what you want to do is use those polygon boundaries as the basis for querying from a larger drawing. ie a new drawing for each 1/4 section. What you can use are plot sets.
What is a plot set?
Will it provide me with the following data:
(ade_qrydefine '("" "" "" "Location" ("polyline" "polygon" "inside" 1 (0 0 1) 0.000000 (1.18173e+006 271156 0) 0.000000 (1.19751e+006 271156 0) 0.000000 (1.19707e+006 257360 0) 0.000000 (1.19706e+006 257003 0) 0.000000 (1.19701e+006 256004 0) 0.000000 (1.19697e+006 255005 0) 0.000000 (1.19693e+006 254006 0) 0.000000 (1.19689e+006 253007 0) 0.000000 (1.19685e+006 252007 0) 0.000000 (1.19684e+006 251850 0) 0.000000 (1.19679e+006 250852 0) 0.000000 (1.19673e+006 249853 0) 0.000000 (1.19668e+006 248855 0) 0.000000 (1.19663e+006 247856 0) 0.000000 (1.19657e+006 246857 0) 0.000000 (1.19562e+006 246886 0) 0.000000 (1.19462e+006 246917 0) 0.000000 (1.19362e+006 246947 0) 0.000000 (1.19262e+006 246977 0) 0.000000 (1.19162e+006 247007 0) 0.000000 (1.19122e+006 247013 0) 0.000000 (1.19022e+006 247026 0) 0.000000 (1.18922e+006 247039 0) 0.000000 (1.18822e+006 247052 0) 0.000000 (1.18722e+006 247065 0) 0.000000 (1.18622e+006 247078 0) 0.000000 (1.18592e+006 247085 0) 0.000000 (1.18492e+006 247109 0) 0.000000 (1.18392e+006 247133 0) 0.000000 (1.18357e+006 247142 0) 0.000000 (1.18292e+006 247154 0) 0.000000 (1.18192e+006 247173 0) 0.000000 (1.18092e+006 247193 0) 0.000000 (1.18096e+006 248192 0) 0.000000 (1.181e+006 249191 0) 0.000000 (1.18104e+006 250190 0) 0.000000 (1.18109e+006 251189 0) 0.000000 (1.18113e+006 252188 0) 0.000000 (1.18114e+006 252498 0) 0.000000 (1.18117e+006 253497 0) 0.000000 (1.1812e+006 254497 0) 0.000000 (1.18122e+006 255496 0) 0.000000 (1.18125e+006 256496 0) 0.000000 (1.18128e+006 257496 0) 0.000000 (1.18129e+006 257777 0) 0.000000 (1.18132e+006 258776 0) 0.000000 (1.18135e+006 259776 0) 0.000000 (1.18173e+006 271156 0))""))
Rob
mohobrien
2005-09-01, 09:59 PM
Not directly but it approaches the problem from a slightly different angle. The drawing that contains all the 1/4 sections (with appropriate unique ID attached as object data to the individual 1/4 sections) is used as the source of the location part of the query. The coordinates of the polygon are picked up automatically by simply calling the ID. The plot map set routines are in the command MAPPLOT. It's a far slicker way to plot than by rolling your own. If things are a little different in your situation, you can roll your own with the (map_pltXXX) routines in the map api.
rad.77676
2005-09-01, 10:10 PM
M,
If you recall, you helped me put together a lisp routine "qsect.lsp" to query and wblock GIS data.
I don't need to plot, I'm still trying to break apart GIS data into drawing files small enough for our designers to be able to open.
That mean using quarter section boundaries, there are approx. 3000 quarter sections in clark county, WA.
The long route would be to define query, select boundary to specify location and save as external query file.
I'm just trying to find a way to avoid that time consuming task.
I just need a way to extract the location of each quarter section to create a query for each.
Rob
mohobrien
2005-09-02, 04:38 PM
If you have the q section id attached as object data, you could use this to make the queries.
You'll have to change the layer name, OD table name and other specific stuff obviously and also probably add a little more to what is written in the query so that it matches what you already have. Also, I'm not sure if a 3d point or just a 2d point is required in the query. But thats easy to change. Hope this is useful.
(defun c:mkqries (/)
(setq sslist ; get the qsection polygon boundaries
(ssget
"x"
(list (cons 0 "LWPOLYLINE") (cons 8 "Q_SECTION_LAYER"))
)
)
(while (> (sslength sslist) 0)
(setq coordlist (mapcar 'cdr ; get the coordinate list
(vl-remove-if-not
'(lambda (x) (= 10 (car x)))
(entget (ssname sslist 0))
)
)
)
(setq disp_number ;get the qsection id from object data
(ade_odgetfield
(ssname sslist 0) ; ename
"disp" ; table name
"disp_num" ; field name
0
)
)
(setq ; open new query file to write
fn (open (strcat "c:\\Drawings\\querytest\\" disp_number ".qry")
"w"
)
)
(write-line
"(ade_qrydefine '(\"\" \"\" \"\" \"Location\" (\"polygon\" \"crossing\" "
fn
)
(foreach y coordlist
(setq a (rtos (car y)))
(setq b (rtos (cadr y)))
(setq c (strcat "(" a " " b ")"))
(write-line c fn)
)
(write-line ")\"\"))" fn)
(write-line "\n" fn)
(ssdel (ssname sslist 0) sslist)
(close fn)
)
(princ)
)
rad.77676
2005-09-02, 05:16 PM
(setq disp_number ;get the qsection id from object data
(ade_odgetfield
(ssname sslist 0) ; ename
"table1" ; table name
"boundaries" ; field name
0
)
)
Mo,
I'm assuming that this is to retrieve qsection id from Access Table?
This function returns nil
Not sure why, I checked to make sure my database was connected, table and field names are correct.
Any ideas?
Rob
mohobrien
2005-09-02, 05:32 PM
Actually no. Its trying to pickup attached object data. When you get your original gis data, how do they identify the qsections? That's the most important question.
rad.77676
2005-09-02, 05:41 PM
(setq disp_number ;get the qsection id from object data
(ade_odgetfield
(ssname sslist 0) ; ename
"qsection" ; table name
"legal" ; field name
0
)
)
I changed previous code to retrieve object data "legal description" and the following is returned.
(mkqries)
(ade_qrydefine '("" "" "" "Location" ("polygon" "crossing"
(1192013.1250 80205.1641)
(1191865.6250 77508.4375)
(1189200.1250 77809.1016)
(1189358.2500 80507.0938)
(1192013.1250 80205.1641)
)""))
; error: bad argument type: streamp nil
It seems to return to correct info, but comes up with error?
Rob
mohobrien
2005-09-02, 05:46 PM
If I could get even just a piece of the dwg that your qsections are on and maybe a subset of you db, it would go a lot faster.
rad.77676
2005-09-02, 05:58 PM
Mo,
Here is the quarter section drawing with database and lisp.
Rob
mohobrien
2005-09-02, 06:03 PM
Lunch time for me. I'm two hours ahead. I'll take a look after.
mohobrien
2005-09-02, 07:03 PM
Turns out its my turn to stay through lunch and go home early. Whoopie. Long weekend for us!
Actually, you don't need the db since all the info is in the object data.
You're getting the error message because the filename you're trying to write is like this:
NW1/4,S32,T6N,R4E.qry That's an illegal name. Can't have , or /.
Insert this right after you setq the variable disp_number. Not very elegant but it removes the offending characters.
(setq disp_number(vl-string-translate "/" (chr 32) disp_number))
(setq disp_number(vl-string-translate "," (chr 32) disp_number))
I tried it here and it works here. Also the query seems valid.
rad.77676
2005-09-02, 07:55 PM
Mo,
Thanks for all your help, I think that might get me where I need to go.
I'm gonna have to work on the query file names a bit, but I'm pretty sure that'll do it.
Rob
rad.77676
2005-09-15, 06:40 PM
Hey Mo,
Maybe you can help me figure this out.
I started this routine last night when I left at 4:17pm and when I arrived this morning, it had crashed and the error stated that the routine was asking the acad.exe to shut down in a non standard way?
It ran for 8hrs 40min and had queried 223 drawings of 2836 total.
Any idea what might be going on here?
Thanks,
Rob
mohobrien
2005-09-16, 12:27 AM
I haven't got a clue. The first thing I'd do is load the windows task manager, keep it on top and run the routine. Just need to see if there is a steady decrease memory. If there is, well there's a leak somewhere and perhaps there may be a workaround. If not well maybe autosave affects autocad. Maybe out of disk space? but that usually gives a write error. I haven't heard of that before. When I've goofed and written an endless loop writing a file, it's filled the disk but it never took 8 hours.
Anybody else got any suggestions?
http://discussion.autodesk.com/thread.jspa?threadID=384153
Maybe this might apply? I'll see what I can come up with. I'm out of town next week for a few days
mohobrien
2005-09-16, 08:50 PM
It seems like the approach suggested by both MHultgren and JimDahl in the beginning of this thread would have been better than my approach. Actually, it is very easy working with dbs in lisp if you use the free library supplied by Jon Fleming at http://acad.fleming-group.com/index.html. I'll post a rewrite next week after I get back.
rad.77676
2005-09-19, 05:43 PM
Mo,
Just a heads up, I broke out the qsections drawing into smaller pieces and it seems to be fine.
Thanks for all your help.
Rob
rad.77676
2005-09-29, 08:10 PM
Are you wanting to save the window limits of each one or just the centroid? If you have LDT, place a point at the intersections and you can export the coords (X.Y.and Z - if needed) to a file. and then build a template query to pull in the type of data you want, then use the ol' cut - n - paste (in your favorite ascii editor) to change the coordinates for each section, do a save-as with section number or something that makes sense. Here is the format of the qry file. Make sure that you have created your project info prior to generating the template, build your query and run it on the first section to make sure you have everything you need showing, then save that to an external file. Open that file and look for the areas in red below to see what you would need to change. I would probably round off the coordinates and give yourself a bit of a buffer ( add or subtract 10 to each X and Y coordinate to make sure your get the whole section.
Once you build your "Template query, you should only have to change the coords and do a save-as.
Mark,
Can you export points from LDT to Access Database?
Rob
MHultgren
2005-09-29, 08:16 PM
Actually, you don't have to export them, they are already in an MDB under the Project Folder - cogo-points.mdb. Depending on the release, I believe the DB is in MSAccess97 format. You don't want to change the format or you will not be able to use them in LDT until your export\repair it back down to the older version.
rad.77676
2005-09-29, 08:21 PM
Mark,
So if I were to place points at all intersections of my topo and wanted to setup a database to link to my topo, I could save this database and setup the links to it.
Correct?
This would give me the coordinates for each quarter section.
Rob
MHultgren
2005-09-29, 08:45 PM
Rob,
When you create the points using LDT, the database is built for you. This is why I suggested that approach in the beginning. Why do all the extra work? Let the software create the points AND the DB.Then when you define your query, just add a "fudge factor to the coordinates to make sure that you get everything inside your bounding box. Something along the lines of If PTX1 Less than PTx2 then set PTX1 to PTX1-5 and set PTX2 to PTX2+5. Where PT is your point, X would be the easting coordinate and 1 -2 would be the point listing. So it would look at the X or easting of one point in the list and compare that to the next point in the list and if the first one was lower, then it would take that coordinate and subtract, say 5' from itand you would need to do the same for the Northings as well to create your bounding box with an offset from each corner of 5' east and 5' north in this case. Then use those coords for your limits of the query. So if you had 4 points with coords of (1,1), (1,0), (0,1), (0,0) your query would end up using coordinates of (6,6 ), (6,-5), (-5,6) and (-5,-5).
Hope I explained this correctly.
rad.77676
2005-09-29, 09:37 PM
Rob,
Then when you define your query, just add a "fudge factor to the coordinates to make sure that you get everything inside your bounding box.
Hope I explained this correctly.
Mark,
Currently I am using an ssget function to obtain coordinates from polyline boundaries and writing them to external query files.
If the coordinates are in the database, then I wouldn't be defining the location query in my lisp routine as it is now?
I think what you are saying is to set the location inside the query file?
If so, how do I get the coordinates from the database into the query file and what is the advantage of having a database?
If I go through the trouble of setting this up, will it keep map from eating memory as I query?
I guess I don't understand how storing this data inside an external database is going to help.
Also, extending the boundary 5' and using the polygon feature isn't going to help if the layers cross perpendicular to the boundary, unless I'm missing something?
Thank you,
Rob
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.