Mission Planner by Michael Oborne is an impressive piece of software. It is used to program the open-source APM autopilot. The autopilot is used to control planes, copters and rovers. I have used Mission Planner a lot and I can not do without.
Some years ago I started making a map for the Mindland island in the archipelago of Norway using a GPS, OpenStreetMap and Bing aerial imagery. The main driver for this project was to document old place names. With the drones becoming somewhat of a hobby last year I thought it would be nice to also establish a proper open license ortophoto for the island. Mission planner has what it takes to approach such a task in a structured manner, save for one thing. The polygon tool only imports .poly-files.
When working with maps some of us tend to stick with shapefiles or geodatabases. I have made a small script which allows for the conversion of a shapefile with a geographic coordinate system (wgs84) to as many .poly files as there are objects in the shapefile. Adding the functionality to Mission Planner has been indicated as possible, but has yet to materialise. So until then the script associated with this posting remains relevant.My challenge is to take aerial photogray of Mindland, a small island in the Nordland county in Norway. The island coastline is around 24 kms and the area is around 14 km2.
To do this it is necessary to make a flight plan covering the whole island. I will of course have to do it according to regulations and relevant insurance agreements. The first job was to decide on the size of the grids.
In Norway the regulations state that you can not operate an model aircraft from a distance of more than 400 meters. Planning a survey using circles does not work – so with some rather simple mathematics I figured that the square of 565 by 565 meters would be the biggest legal square size I could work with on my survey.
With the legal issues under control I used a GIS program to create an indexed shapefile with grid square polygons. The grids squares overlapping with the island were selected and I then ended up with 95 squares covering the island and associated archipelago. The grids will serve as my survey plan.
The above grid square file format is .shp. The shapefile format is a de facto standard for storing spatial data for the purpose of analysis and presentation. Since it is necessary to import the grids to Mission Planner, I made a script which does the job. You may download a version of the software here:
- shape_to_poly (version 0.5)
This is what the code does:
- Read a named shapefile
- Iterate through the individual objects (preferably polygons) in the shapefile
- Read an object
- Iterate through the coordinates for the polygon
- Initiate a file according to the naming convention
- Write all coordinates into the file
The script converts all squares in the shapefile to individual .poly files. The names of the files are according to the names used in the above map. If we go back to the grid I will use it to plan a the survey for grid 15-9:
After converting the polygons in the shapefile the same grid looks like this when loaded into Mission Planner:
Using Mission Planner Auto WP, selecting Survey (Grid) we are easily able to get this flight plan:
If we import another .poly-file we can actually extend the survey.
With this I hope that the script and it’s use has been presented in a relevant manner. Please contact me shouldyou have any questions.
Hai Ragnvald Larsen,
thank you for this wonderful information.
how to install shape_to_poly package.
after downloading there is no .exe file ?
The code runs under python, so you will have to install python on your computer. But I think the software missionplanner now supports this so the code is thus redundant 🙂
Are you saying that mission planner 1.X import shape files?
After downloading the file should I change the ending to .py?
Open Mission Planner an press Ctrl-F. This will open a page with buttons. One of them is Shp to Poly. So it works out of the box 🙂