AutoCAD Map 3D Forum
Welcome to Autodesk’s AutoCAD Map 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Query: count multiple objects (points) inside multiple area's (mpolygon)

15 REPLIES 15
Reply
Message 1 of 16
MarkFissers1310
616 Views, 15 Replies

Query: count multiple objects (points) inside multiple area's (mpolygon)

Hi,

Can someone help me with an example of a Query that counts multiple objects (points) inside multiple area's (mpolygons)?

Example: I've got multiple area's, and inside these area's are multiple points. I would like to see as a result the total number of points inside these area's... by area.

 

Thank you in advance,

Mark

15 REPLIES 15
Message 2 of 16

Hello @MarkFissers1310 

Please be more specific.

 

  1. What are your points? Shapefile? Gdb? Plain vanilla AutoCAD objects? AutoCAD entities with Object Data?Something else?  Both your object type and object format play critical roles when formulizing a solution.
  2. Are the polygon objects physically drawn in modelspace? Or are they 'imaginary' areas that can only be visualized by you? If Map3D cannot 'see' areas defined by your polygons then you won't be able to reach a resolution.
  3. Please thoroughly explain what you plan to do with the points once they're counted--there might be a more elegant way to achieve what you're after without counting the points in the first place.

Would you be willing to upload your points and your dwg file for a speedy and detailed workflow?

 

Chicagolooper
Message 3 of 16
braudpat
in reply to: MarkFissers1310

Hello

 

You want to count objects like Points, Blocks/Symbols inside MPolygons !?

 

It's very difficult especially when you have complex MPolygons with multiples complex holes and sub-holes ...

 

Please a DWG ... Or 2 SHPs : one with Polygons / MPolygons and the other with Points ?

 

The Health, Bye, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 4 of 16

How can I share sdf or shp files ?

Looks like both files are blocked...

Kind regards,

Mark

Message 5 of 16

For SDF, click-and-drag the SDF. From the WINDOWS EXPLORER folder, left-click the SDF and drag it. Drop it here. 

 

101.JPG

 

 

For shapefile: make sure all four parts are in a single folder. The 4 parts are (a) shp, (b) shx, (c) dbf and (d) prj. These are the minimum number of parts to a shapefile. You may have more parts (they'er extra) but the four mentioned are mandatory. You can click-drag-and-drop just like the SDF.

102.JPG

 

Before you click-drag-and-drop the zipped shapefile, you can create a compressed zip folder by RIGHT-CLICKING the folder then doing this: If you don't zip the folder, you'll need to click-drag-and-drop the ALL four parts as a GROUP or each part individually.

 

103.jpg

Chicagolooper
Message 6 of 16

Thank you for the explanation (is much appreciated)

Hereby are two zip files containing the shp files + shx, dbf, prj, ...

 

Grtz, Mark

Message 7 of 16
parkr4st
in reply to: MarkFissers1310

attached files

your data to a map, analyse, intersection to the sdf file, data table from the sdf to .csv which can be sorted and reported as you please.  I chose access DB.

 

BTW no .prj files so your data is not georefernced as pointed out.

 

There are other ways that will get posted for sure.

 

Message 8 of 16
TerryDotson
in reply to: braudpat


It's very difficult especially when you have complex MPolygons with multiples complex holes and sub-holes ...

Good advice but unless I've overlooked something, these boundaries do not have any holes.  Can't the OP simply use the SELECT command, window (most cases) and use the "### Found" information echoed at the command prompt?

Message 9 of 16
MarkFissers1310
in reply to: parkr4st

Thanks for your reply.

Is it possible to get as a result something like the table below?

 

FeatIdNumberType_NType_JType_RType_L
1R05    
2R03    
3R02    
4R01    
5L04    
6L03    
7L02    
Message 10 of 16

I had something dynamic in mind rather than a manual selection ;o)
Message 11 of 16

I had something dynamic in mind rather than a manual selection ;o)

If you still need results from this dataset, take a look at the attached.

Message 12 of 16

Looks nice 👍

 

I have 2 questions:

1) what is the workflow (query in AutoCAD MAP) to get this result?

2) is it possible to expand the data-table of the polygon shape-file with those additional columns?

 

Grtz, Mark

Message 13 of 16
parkr4st
in reply to: MarkFissers1310

one method to add the columns

First set a geographic coordinate system.   This should be done with all maps to georeference the data.

Next create a new SDF file with geometry set so  surface

and 4 new properties Type_N,J, R, & L

Put the sdf into the map and find create a new feature in the right click menu in Display Manager and draw a polygon around all the polygons in your map

Analyze, original polygons, new polygons as source and overlay respectfully, set a new file name for the output file and finish

The new polygons will have the columns in the table where the desired data can be filled in.

The original polygons file can be removed from the map as it is no longer needed

The data files in the .zip have all the data decribed above.  ME83-W is used as the GCS.  The GCS is needed to create a new sdf file, so set the GCS first in the local of you data.  Post for help if needed.

 

as for the excel file, export the data file to a .csv file and use excel, other spreadsheet or database software to work with the data.

 

Message 14 of 16


1) what is the workflow (query in AutoCAD MAP) to get this result?

This is actually a new dedicated inquiry tool we're adding to our add-on software packages for AutoCAD and Civil3D.  We felt it was likely users may want to report on counts per data value such as your case and others like total single family homes by subdivision block, etc.

 

FigConCnt.png

 


2) is it possible to expand the data-table of the polygon shape-file with those additional columns?

Not currently, we need to add column adding capabilities to our data write driver first.  Then we will add the ability to add these columns to the outer polygon data.

Message 15 of 16

I do a similar operation using QGIS.  It has many powerful algorithms for analysis that are not present in Map. 

Message 16 of 16


@MarkFissers1310  a écrit :

Thanks for your reply.

Is it possible to get as a result something like the table below?

 

FeatIdNumberType_NType_JType_RType_L
1R05    
2R03    
3R02    
4R01    
5L04    
6L03    
7L02    

@MarkFissers1310 

With this?

 

(defun c:extract_data ( / ss n e v data_lst-mp p lst_pt ss_pt dn dj dr dl nb ep data_p data)
  (defun WriteExcel (data / xlApp wBook cells i j)
    (setq
      xlApp (vlax-create-object "Excel.Application")
      wBook (vlax-invoke-method (vlax-get-property xlapp 'WorkBooks) 'Add)
      cells (vlax-get-property xlApp 'Cells)
      i 0
    )
    (foreach row data
      (setq i (1+ i) j 0)
      (foreach val row
        (setq
          j (1+ j)
          cell (vlax-variant-value (vlax-get-property cells 'Item i j))
        )
        (vlax-put-property cell 'Value2 val)
      )
    )
    (vlax-invoke-method
      (vlax-get-property
        (vlax-get-property xlApp 'ActiveSheet)
        'Columns
      )
      'AutoFit
    )
    (vlax-put-Property xlApp 'Visible :vlax-true)
  )
  (defun f (l i)
    (if (> i 0)
      (cons (mapcar (function +) (car l) v) (f (cdr l) (1- i)))
    )
  )
  (setq ss (ssget "_X" '((0 . "MPOLYGON") (8 . "polygons"))))
  (repeat (setq n (sslength ss))
    (setq
      e (entget (ssname ss (setq n (1- n))))
      v (cons 0 (mapcar (function -) (cdr (assoc 11 e)) (cdr (assoc 10 e))))
    )
    (setq
      data_lst-mp
      (mapcar
        '(lambda (x) (ade_odgetfield (cdar e) "polygons" x 0))
        '("FeatId" "Number")
      )
    )
    (while (setq e (member (assoc 93 (cdr e)) (cdr e)))
      (setq p (f (cdr e) (cdar e)))
    )
    (setq
      lst_pt (mapcar 'cdr p)
      ss_pt (ssget "_WP" lst_pt '((0 . "POINT") (8 . "points")))
      dn 0 dj 0 dr 0 dl 0
    )
    (repeat (setq nb (sslength ss_pt))
      (setq
        ep (ssname ss_pt (setq nb (1- nb)))
        data_p (ade_odgetfield ep "points" "Type" 0)
      )
      (cond
        ((eq data_p "N") (setq dn (1+ dn)))
        ((eq data_p "J") (setq dj (1+ dj)))
        ((eq data_p "R") (setq dr (1+ dr)))
        ((eq data_p "L") (setq dl (1+ dl)))
      )
    )
    (setq data (cons (append data_lst-mp (list dn dj dr dl)) data))
  )
  (if data
    (WriteExcel (cons (list "FeatId" "Number" "Type_N" "Type_J" "Type_R" "Type_L") (reverse data)))
  )
  (prin1)
)

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report