Forum Discussion

samahiji's avatar
samahiji
Frequent Visitor
1 year ago
Solved

check if coordinates are within certain polygon

Hi,

I have two tables:

Table 1 contains all X Y coordinates 

Table 2 contains the polygon shape file coordinates,

 

I want to check which coordinates are within the polygon. 

 

 

9 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    samahiji Sorry, having trouble following, can you post sample data as text and expected output?
    Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

    Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

  • v-sgandrathi's avatar
    v-sgandrathi
    Community Support

    Hi samahiji,
    Thank you for reaching out to the Microsoft Fabric Community forum.

    Here I have taken 2 sample datasets as per information and did the steps for your understanding, but it will be better for us to perform steps accurately and we can guide you accordingly if you can provide us the Data if possible.
    This process can be done in many ways, where I followed DAX queries to perform.

     

    For your Idea, I’ve attached the PBIX file with the implemented solution. Please review it and let us know is there any further questions.

    If this post helps, please give us Kudos and consider Accept it as a solution to help the other members find it more easily.

     

    Best Regards,
    Sahasra.

  • p45cal's avatar
    p45cal
    Solution Supplier

    Yes, let's have some tables from you. Preferably in an app (say Excel as a workbook).

    I've been working on polygons like this and have (I think) been successful (purely in Power Query) but I won't post my offering (because it's a mess, currently) until I have a good idea of how your data arrives and how you want it to show at the end.

     

     

     

     

     

    • samahiji's avatar
      samahiji
      Frequent Visitor

      Hi p45cal ,

      That's exactly what I want. My data is huge, attached is a sample of it. I have two tables, the polygon X&Y is in sheet "Polygon", the data point is in another sheet "Points". A new column "IN/OUT" in sheet "Points" is calculated with 0 if out, 1 if in.

       

      unfortunately, I can't upload the file, here is a snapshot.

       

       

      • p45cal's avatar
        p45cal
        Solution Supplier

        My data is huge,
        <snip>

        unfortunately, I can't upload the file, here is a snapshot.


        1. Upload it to a file sharing site or onedrive, dropbox, box.com, googledrive etc. there are loads of them, and drop the link to it here.

        If it contains sensitive info delete all unnecessary sheets and just supply two tables on two sheets. Pictures aren't much use.

         

        2. Does it have to be Power Query? Could it be a custom user-defined function in vba (a macro)?

         

  • I used the sample data provided by p45cal. Maybe you want this.

     

    • ZhangKun's avatar
      ZhangKun
      Super User

      samahiji You can leave your e-mail and i'll reply you with source code(about today or tomorrow).

      • Mic_Maz's avatar
        Mic_Maz
        New Member

        Hello there,

         

        I'm working on a similar conundrum. Do you still have the code to work on this?